diff --git a/core/src/main/java/jenkins/model/Nodes.java b/core/src/main/java/jenkins/model/Nodes.java index a01c3fc342b5..ae78028c2d2f 100644 --- a/core/src/main/java/jenkins/model/Nodes.java +++ b/core/src/main/java/jenkins/model/Nodes.java @@ -118,6 +118,8 @@ public void setNodes(final @NonNull Collection 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); @@ -125,8 +127,6 @@ public void setNodes(final @NonNull Collection nodes) throws IOE } else { NodeListener.fireOnCreated(node); } - Nodes.this.nodes.put(name, node); - node.onLoad(Nodes.this, name); } Nodes.this.nodes.keySet().removeAll(toRemove.keySet()); jenkins.updateComputerList(); diff --git a/test/src/test/java/jenkins/model/NodesTest.java b/test/src/test/java/jenkins/model/NodesTest.java index ef2bee08ef4a..5b222e313a5f 100644 --- a/test/src/test/java/jenkins/model/NodesTest.java +++ b/test/src/test/java/jenkins/model/NodesTest.java @@ -287,6 +287,7 @@ public static class CheckSetNodes extends NodeListener { @Override protected void onCreated(@NonNull Node node) { + node.getRootDir(); created.add(node.getNodeName()); }