diff --git a/core/src/main/java/hudson/model/Computer.java b/core/src/main/java/hudson/model/Computer.java index 9400a70d3f53..3cb7618ed3a9 100644 --- a/core/src/main/java/hudson/model/Computer.java +++ b/core/src/main/java/hudson/model/Computer.java @@ -1095,7 +1095,6 @@ public final long getDemandStartMilliseconds() { */ protected void removeExecutor(final Executor e) { final Runnable task = () -> { - var idle = false; synchronized (Computer.this) { executors.remove(e); oneOffExecutors.remove(e); @@ -1105,13 +1104,10 @@ protected void removeExecutor(final Executor e) { if (ciBase != null) { // TODO confirm safe to assume non-null and use getInstance() ciBase.removeComputer(Computer.this); } - } else { - idle = isIdle(); + } else if (isIdle()) { + threadPoolForRemoting.submit(() -> Listeners.notify(ComputerListener.class, false, l -> l.onIdle(this))); } } - if (idle) { - Listeners.notify(ComputerListener.class, false, l -> l.onIdle(this)); - } }; if (!Queue.tryWithLock(task)) { // JENKINS-28840 if we couldn't get the lock push the operation to a separate thread to avoid deadlocks