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); } diff --git a/artemis-journal/src/test/java/org/apache/activemq/artemis/core/io/aio/CallbackOrderTest.java b/artemis-journal/src/test/java/org/apache/activemq/artemis/core/io/aio/CallbackOrderTest.java index fa7868763f..0495c28a64 100644 --- a/artemis-journal/src/test/java/org/apache/activemq/artemis/core/io/aio/CallbackOrderTest.java +++ b/artemis-journal/src/test/java/org/apache/activemq/artemis/core/io/aio/CallbackOrderTest.java @@ -68,7 +68,6 @@ public class CallbackOrderTest { // We will repeat the test a few times, increasing N // to increase possibility of issues due to reuse of callbacks for (int n = 1; n < 100; n++) { - System.out.println("n = " + n); int N = n; count.set(0); list.clear(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/management/OpenWireManagementTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/management/OpenWireManagementTest.java index 6a31a482b4..3f930c9df6 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/management/OpenWireManagementTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/management/OpenWireManagementTest.java @@ -110,7 +110,7 @@ public class OpenWireManagementTest extends OpenWireTestBase { String[] addresses = serverControl.getAddressNames(); - assertEquals(3, addresses.length); + assertEquals(4, addresses.length); for (String addr : addresses) { assertFalse(addr.startsWith(AdvisorySupport.ADVISORY_TOPIC_PREFIX)); }