Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure NodeListener#onCreated is called once the Node initialization is complete #9964

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
res0nance marked this conversation as resolved.
Show resolved Hide resolved
created.add(node.getNodeName());
}

Expand Down
Loading