From 168a95d334ecc102ff505ecca4c9b47a152dee1a Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Thu, 19 Sep 2019 08:56:01 +1000 Subject: [PATCH] Issue #4096 - allow thread to exit ReservedThreadExecutor on stop Signed-off-by: Lachlan Roberts --- .../eclipse/jetty/util/thread/ReservedThreadExecutor.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ReservedThreadExecutor.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ReservedThreadExecutor.java index f17271670d6..37173216848 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ReservedThreadExecutor.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ReservedThreadExecutor.java @@ -163,6 +163,9 @@ public class ReservedThreadExecutor extends AbstractLifeCycle implements TryExec { if (_lease != null) _lease.close(); + + super.doStop(); + while (true) { ReservedThread thread = _stack.pollFirst(); @@ -171,7 +174,6 @@ public class ReservedThreadExecutor extends AbstractLifeCycle implements TryExec _size.decrementAndGet(); thread.stop(); } - super.doStop(); } @Override @@ -277,7 +279,7 @@ public class ReservedThreadExecutor extends AbstractLifeCycle implements TryExec LOG.debug("{} waiting", this); Runnable task = null; - while (task == null) + while (isRunning() && task == null) { boolean idle = false;