From cb6941ee0b49358ee4ad0700e3f672e7ffae5dcb Mon Sep 17 00:00:00 2001 From: gtully Date: Thu, 20 Mar 2014 14:13:39 +0000 Subject: [PATCH] https://issues.apache.org/jira/browse/AMQ-4886 - think the sync on shutdown issue is resolved and the test will no longer hang --- .../apache/activemq/leveldb/LevelDBClient.scala | 17 ++++++++++++----- .../org/apache/activemq/bugs/AMQ2149Test.java | 7 ++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/LevelDBClient.scala b/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/LevelDBClient.scala index f69cb4c25e..8f6561533a 100755 --- a/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/LevelDBClient.scala +++ b/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/LevelDBClient.scala @@ -979,11 +979,18 @@ class LevelDBClient(store: LevelDBStore) { ingorefailure(might_fail(throw new IOException("non-clean close"))) } - def stop():Unit = this.synchronized { - if( writeExecutor!=null ) { - writeExecutor.shutdown - writeExecutor.awaitTermination(60, TimeUnit.SECONDS) - writeExecutor = null + def stop():Unit = { + var executorToShutdown:ExecutorService = null + this synchronized { + if (writeExecutor != null) { + executorToShutdown = writeExecutor + writeExecutor = null + } + } + + if (executorToShutdown != null) { + executorToShutdown.shutdown + executorToShutdown.awaitTermination(60, TimeUnit.SECONDS) // this blocks until all io completes.. snapshotRwLock.writeLock().lock() diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2149Test.java b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2149Test.java index ee80c08c6b..b2eba61366 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2149Test.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2149Test.java @@ -522,14 +522,11 @@ public class AMQ2149Test { final long expiry = System.currentTimeMillis() + 1000 * 60 * 4; while(!threads.isEmpty() && exceptions.isEmpty() && System.currentTimeMillis() < expiry) { Thread sendThread = threads.firstElement(); - sendThread.join(1000*20); + sendThread.join(1000*30); if (!sendThread.isAlive()) { threads.remove(sendThread); } else { - Throwable throwable = new Throwable("blocked send thread"); - throwable.setStackTrace(sendThread.getStackTrace()); - LOG.error("Send thread blocked", throwable); - throwable.printStackTrace(); + AutoFailTestSupport.dumpAllThreads("Send blocked"); } } LOG.info("senders done..." + threads);