This commit is contained in:
Francesco Nigro 2018-07-12 16:51:35 +02:00
commit 2d91a739e2
4 changed files with 32 additions and 20 deletions

View File

@ -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 {

View File

@ -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;

View File

@ -26,4 +26,10 @@ public class SpawnedVMCheck extends ExternalResource {
super.after();
SpawnedVMSupport.checkProcess();
}
@Override
public void before() throws Throwable {
super.before();
SpawnedVMSupport.enableCheck();
}
}

View File

@ -40,7 +40,7 @@ import static java.util.concurrent.TimeUnit.SECONDS;
public final class SpawnedVMSupport {
static ConcurrentHashMap<Process, String> startedProcesses = new ConcurrentHashMap();
static ConcurrentHashMap<Process, String> 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<Process> 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<Process> 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;
}
}