From ed93ad020ae2e092242a89c6b714dca67c472559 Mon Sep 17 00:00:00 2001 From: Vincent Latombe Date: Wed, 28 Aug 2024 16:12:09 +0200 Subject: [PATCH] Revert "Call listener synchronously, but outside synchronized" This reverts commit 75242cf03010509e968f9de1a00ca6bb19d8b5fa. --- core/src/main/java/hudson/model/Computer.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) 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