Skip to content

Commit

Permalink
Ensure NodeListener#onCreated is called once the Node initialization …
Browse files Browse the repository at this point in the history
…is complete (#9964)
  • Loading branch information
Vlatombe authored Nov 28, 2024
1 parent a07ccae commit 0235a80
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/jenkins/model/Nodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ public void setNodes(final @NonNull Collection<? extends Node> nodes) throws IOE
toRemove.putAll(Nodes.this.nodes);
for (var node : nodes) {
final var name = node.getNodeName();
Nodes.this.nodes.put(name, node);
node.onLoad(Nodes.this, name);
var oldNode = toRemove.get(name);
if (oldNode != null) {
NodeListener.fireOnUpdated(oldNode, node);
toRemove.remove(name);
} else {
NodeListener.fireOnCreated(node);
}
Nodes.this.nodes.put(name, node);
node.onLoad(Nodes.this, name);
}
Nodes.this.nodes.keySet().removeAll(toRemove.keySet());
jenkins.updateComputerList();
Expand Down
1 change: 1 addition & 0 deletions test/src/test/java/jenkins/model/NodesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ public static class CheckSetNodes extends NodeListener {

@Override
protected void onCreated(@NonNull Node node) {
node.getRootDir();
created.add(node.getNodeName());
}

Expand Down

0 comments on commit 0235a80

Please sign in to comment.