|
27 | 27 |
|
28 | 28 | import edu.umd.cs.findbugs.annotations.CheckForNull; |
29 | 29 | import edu.umd.cs.findbugs.annotations.NonNull; |
| 30 | +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
30 | 31 | import hudson.DescriptorExtensionList; |
31 | 32 | import hudson.EnvVars; |
32 | 33 | import hudson.FilePath; |
|
102 | 103 | * |
103 | 104 | * @author Kohsuke Kawaguchi |
104 | 105 | */ |
| 106 | +@SuppressFBWarnings(value = "DESERIALIZATION_GADGET", justification = "unhappy about existence of readResolve?") |
105 | 107 | public abstract class Slave extends Node implements Serializable { |
106 | 108 |
|
107 | 109 | private static final Logger LOGGER = Logger.getLogger(Slave.class.getName()); |
@@ -381,7 +383,9 @@ private void _setLabelString(String labelString) { |
381 | 383 | @Override |
382 | 384 | protected Set<LabelAtom> getLabelAtomSet() { |
383 | 385 | if (labelAtomSet == null) { |
384 | | - warnPlugin(); |
| 386 | + if (!insideReadResolve.get()) { |
| 387 | + warnPlugin(); |
| 388 | + } |
385 | 389 | this.labelAtomSet = Collections.unmodifiableSet(Label.parse(label)); |
386 | 390 | } |
387 | 391 | return labelAtomSet; |
@@ -627,14 +631,21 @@ public int hashCode() { |
627 | 631 | return name.hashCode(); |
628 | 632 | } |
629 | 633 |
|
| 634 | + private static final ThreadLocal<Boolean> insideReadResolve = ThreadLocal.withInitial(() -> false); |
| 635 | + |
630 | 636 | /** |
631 | 637 | * Invoked by XStream when this object is read into memory. |
632 | 638 | */ |
633 | 639 | protected Object readResolve() { |
634 | 640 | if (nodeProperties == null) |
635 | 641 | nodeProperties = new DescribableList<>(this); |
636 | 642 | previouslyAssignedLabels = new HashSet<>(); |
637 | | - _setLabelString(label); |
| 643 | + insideReadResolve.set(true); |
| 644 | + try { |
| 645 | + _setLabelString(label); |
| 646 | + } finally { |
| 647 | + insideReadResolve.set(false); |
| 648 | + } |
638 | 649 | return this; |
639 | 650 | } |
640 | 651 |
|
|
0 commit comments