mirror of https://github.com/jenkinsci/jenkins.git
Avoid warning about `labelAtomSet` during `Slave.readResolve` (#10863)
This commit is contained in:
commit
de9058e8f8
|
@ -27,6 +27,7 @@ package hudson.model;
|
||||||
|
|
||||||
import edu.umd.cs.findbugs.annotations.CheckForNull;
|
import edu.umd.cs.findbugs.annotations.CheckForNull;
|
||||||
import edu.umd.cs.findbugs.annotations.NonNull;
|
import edu.umd.cs.findbugs.annotations.NonNull;
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
import hudson.DescriptorExtensionList;
|
import hudson.DescriptorExtensionList;
|
||||||
import hudson.EnvVars;
|
import hudson.EnvVars;
|
||||||
import hudson.FilePath;
|
import hudson.FilePath;
|
||||||
|
@ -102,6 +103,7 @@ import org.kohsuke.stapler.StaplerResponse2;
|
||||||
*
|
*
|
||||||
* @author Kohsuke Kawaguchi
|
* @author Kohsuke Kawaguchi
|
||||||
*/
|
*/
|
||||||
|
@SuppressFBWarnings(value = "DESERIALIZATION_GADGET", justification = "unhappy about existence of readResolve?")
|
||||||
public abstract class Slave extends Node implements Serializable {
|
public abstract class Slave extends Node implements Serializable {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(Slave.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(Slave.class.getName());
|
||||||
|
@ -381,7 +383,9 @@ public abstract class Slave extends Node implements Serializable {
|
||||||
@Override
|
@Override
|
||||||
protected Set<LabelAtom> getLabelAtomSet() {
|
protected Set<LabelAtom> getLabelAtomSet() {
|
||||||
if (labelAtomSet == null) {
|
if (labelAtomSet == null) {
|
||||||
warnPlugin();
|
if (!insideReadResolve.get()) {
|
||||||
|
warnPlugin();
|
||||||
|
}
|
||||||
this.labelAtomSet = Collections.unmodifiableSet(Label.parse(label));
|
this.labelAtomSet = Collections.unmodifiableSet(Label.parse(label));
|
||||||
}
|
}
|
||||||
return labelAtomSet;
|
return labelAtomSet;
|
||||||
|
@ -627,6 +631,8 @@ public abstract class Slave extends Node implements Serializable {
|
||||||
return name.hashCode();
|
return name.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final ThreadLocal<Boolean> insideReadResolve = ThreadLocal.withInitial(() -> false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoked by XStream when this object is read into memory.
|
* Invoked by XStream when this object is read into memory.
|
||||||
*/
|
*/
|
||||||
|
@ -634,7 +640,12 @@ public abstract class Slave extends Node implements Serializable {
|
||||||
if (nodeProperties == null)
|
if (nodeProperties == null)
|
||||||
nodeProperties = new DescribableList<>(this);
|
nodeProperties = new DescribableList<>(this);
|
||||||
previouslyAssignedLabels = new HashSet<>();
|
previouslyAssignedLabels = new HashSet<>();
|
||||||
_setLabelString(label);
|
insideReadResolve.set(true);
|
||||||
|
try {
|
||||||
|
_setLabelString(label);
|
||||||
|
} finally {
|
||||||
|
insideReadResolve.set(false);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue