From 9a52766e51da1c1499cafe1b50caed3f03b5ab55 Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Wed, 11 Jul 2018 14:34:34 -0400 Subject: [PATCH 1/3] NO-JIRA Removing System.err style debug left by accident This is non critical. The message is only used by Queue.pause ATM. --- .../activemq/artemis/core/server/impl/QueueImpl.java | 7 ------- 1 file changed, 7 deletions(-) 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 { From a1d34f56311f5cc519511eb99e01313ba3f36c35 Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Wed, 11 Jul 2018 14:34:13 -0400 Subject: [PATCH 2/3] NO-JIRA Adding missing check on ClientCrashTest --- .../tests/integration/clientcrash/ClientCrashTest.java | 5 +++++ 1 file changed, 5 insertions(+) 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; From be8c29d4e1b81665aec56b82eee914683eb93bfa Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Wed, 11 Jul 2018 16:25:22 -0400 Subject: [PATCH 3/3] NO-JIRA Improve SpawnVMCheck --- .../artemis/tests/util/SpawnedVMCheck.java | 6 ++++ .../artemis/tests/util/SpawnedVMSupport.java | 34 ++++++++++++------- 2 files changed, 27 insertions(+), 13 deletions(-) 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; } }