4747import java .util .List ;
4848import java .util .Map ;
4949import java .util .TreeMap ;
50- import java .util .concurrent .Callable ;
5150import java .util .concurrent .ConcurrentMap ;
5251import java .util .concurrent .ConcurrentSkipListMap ;
5352import java .util .concurrent .atomic .AtomicBoolean ;
@@ -203,17 +202,18 @@ public XmlFile getConfigFile(String nodeName) {
203202 * @since 1.634
204203 */
205204 public boolean updateNode (final @ NonNull Node node ) throws IOException {
205+ return updateNode (node , true );
206+ }
207+
208+ private boolean updateNode (final @ NonNull Node node , boolean fireListener ) throws IOException {
206209 boolean exists ;
207210 try {
208- exists = Queue .withLock (new Callable <>() {
209- @ Override
210- public Boolean call () throws Exception {
211- if (node == nodes .get (node .getNodeName ())) {
212- jenkins .trimLabels (node );
213- return true ;
214- }
215- return false ;
211+ exists = Queue .withLock (() -> {
212+ if (node == nodes .get (node .getNodeName ())) {
213+ jenkins .trimLabels (node );
214+ return true ;
216215 }
216+ return false ;
217217 });
218218 } catch (RuntimeException e ) {
219219 // should never happen, but if it does let's do the right thing
@@ -225,7 +225,9 @@ public Boolean call() throws Exception {
225225 if (exists ) {
226226 // TODO there is a theoretical race whereby the node instance is updated/removed after lock release
227227 node .save ();
228- // TODO should this fireOnUpdated?
228+ if (fireListener ) {
229+ NodeListener .fireOnUpdated (node , node );
230+ }
229231 return true ;
230232 }
231233 return false ;
@@ -252,7 +254,7 @@ public void run() {
252254 newOne .onLoad (Nodes .this , newOne .getNodeName ());
253255 }
254256 });
255- updateNode (newOne );
257+ updateNode (newOne , false );
256258 if (!newOne .getNodeName ().equals (oldOne .getNodeName ())) {
257259 LOGGER .fine (() -> "deleting " + new File (getRootDir (), oldOne .getNodeName ()));
258260 Util .deleteRecursive (new File (getRootDir (), oldOne .getNodeName ()));
0 commit comments