diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/buffer/TimedBuffer.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/buffer/TimedBuffer.java index 41137d9d0f..9f809de134 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/buffer/TimedBuffer.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/buffer/TimedBuffer.java @@ -170,6 +170,7 @@ public final class TimedBuffer extends CriticalComponentImpl { public void stop() { enterCritical(CRITICAL_PATH_STOP); + Thread localTimer = null; try { // add critical analyzer here.... <<<< synchronized (this) { @@ -190,17 +191,25 @@ public final class TimedBuffer extends CriticalComponentImpl { logRatesTimerTask.cancel(); } - while (timerThread.isAlive()) { - try { - timerThread.join(); - } catch (InterruptedException e) { - throw new ActiveMQInterruptedException(e); - } - } + localTimer = timerThread; + timerThread = null; + } finally { started = false; } } + if (localTimer != null) { + while (localTimer.isAlive()) { + try { + localTimer.join(1000); + if (localTimer.isAlive()) { + localTimer.interrupt(); + } + } catch (InterruptedException e) { + throw new ActiveMQInterruptedException(e); + } + } + } } finally { leaveCritical(CRITICAL_PATH_STOP); }