diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java index fdb0ddd84b..bc5c0c98fe 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java @@ -248,8 +248,6 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { private final ReusableLatch deliveriesInTransit = new ReusableLatch(0); - private volatile boolean caused = false; - private final AtomicLong queueRateCheckTime = new AtomicLong(System.currentTimeMillis()); private final AtomicLong messagesAddedSnapshot = new AtomicLong(0); @@ -766,11 +764,6 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { */ private boolean flushDeliveriesInTransit() { try { - - if (!deliveriesInTransit.await(100, TimeUnit.MILLISECONDS)) { - caused = true; - System.err.println("There are currently " + deliveriesInTransit.getCount() + " credits"); - } if (deliveriesInTransit.await(DELIVERY_TIMEOUT)) { return true; } else { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/ClientCrashTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/ClientCrashTest.java index e9f282e75f..04377b1349 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/ClientCrashTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/ClientCrashTest.java @@ -29,10 +29,12 @@ import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; +import org.apache.activemq.artemis.tests.util.SpawnedVMCheck; import org.apache.activemq.artemis.tests.util.SpawnedVMSupport; import org.junit.After; import org.junit.Assert; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; /** @@ -41,6 +43,9 @@ import org.junit.Test; */ public class ClientCrashTest extends ClientTestBase { + @Rule + public SpawnedVMCheck spawnedVMCheck = new SpawnedVMCheck(); + // using short values so this test can run fast static final int PING_PERIOD = 100; diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMCheck.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMCheck.java index cc1c0430d3..c4832ab36f 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMCheck.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMCheck.java @@ -26,4 +26,10 @@ public class SpawnedVMCheck extends ExternalResource { super.after(); SpawnedVMSupport.checkProcess(); } + + @Override + public void before() throws Throwable { + super.before(); + SpawnedVMSupport.enableCheck(); + } } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java index 544b04ffeb..b8e86e965d 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java @@ -40,7 +40,7 @@ import static java.util.concurrent.TimeUnit.SECONDS; public final class SpawnedVMSupport { - static ConcurrentHashMap startedProcesses = new ConcurrentHashMap(); + static ConcurrentHashMap startedProcesses = null; private static final UnitTestLogger log = UnitTestLogger.LOGGER; @@ -203,7 +203,9 @@ public final class SpawnedVMSupport { ProcessLogger errorLogger = new ProcessLogger(logErrorOutput, process.getErrorStream(), className, wordMatch, wordRunning); errorLogger.start(); - startedProcesses.put(process, className); + if (startedProcesses != null) { + startedProcesses.put(process, className); + } return process; } @@ -216,18 +218,20 @@ public final class SpawnedVMSupport { HashSet aliveProcess = new HashSet<>(); - for (;;) { - try { - aliveProcess.clear(); - for (Process process : startedProcesses.keySet()) { - if (process.isAlive()) { - aliveProcess.add(process); - process.destroyForcibly(); + if (startedProcesses != null) { + for (;;) { + try { + aliveProcess.clear(); + for (Process process : startedProcesses.keySet()) { + if (process.isAlive()) { + aliveProcess.add(process); + process.destroyForcibly(); + } } + break; + } catch (Throwable e) { + e.printStackTrace(); } - break; - } catch (Throwable e) { - e.printStackTrace(); } } @@ -251,6 +255,10 @@ public final class SpawnedVMSupport { } + public static void enableCheck() { + startedProcesses = new ConcurrentHashMap<>(); + } + public static void checkProcess() { HashSet aliveProcess = getAliveProcesses(); @@ -265,7 +273,7 @@ public final class SpawnedVMSupport { Assert.fail("There are " + aliveProcess.size() + " processes alive :: " + buffer.toString()); } } finally { - startedProcesses.clear(); + startedProcesses = null; } }