diff --git a/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java b/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java index d7e9c0254b..1029b95002 100644 --- a/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java +++ b/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java @@ -108,6 +108,7 @@ public class KahaStore implements Store { closed = true; if (initialized) { unlock(); + lockFile.close(); for (ListContainerImpl container : lists.values()) { container.close(); diff --git a/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java b/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java index 6822504bb5..1b0488182c 100644 --- a/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java +++ b/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java @@ -253,11 +253,11 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener, if (!started.compareAndSet(true, false)) { return; } + unlock(); if (lockFile != null) { lockFile.close(); lockFile = null; } - unlock(); this.usageManager.getMemoryUsage().removeUsageListener(this); synchronized (this) { Scheduler.cancel(periodicCheckpointTask); @@ -890,9 +890,12 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener, if (!disableLocking && (null != lock)) { //clear property doesn't work on some platforms System.getProperties().remove(getPropertyKey()); + System.clearProperty(getPropertyKey()); + assert(System.getProperty(getPropertyKey())==null); if (lock.isValid()) { lock.release(); lock.channel().close(); + } lock = null; } diff --git a/activemq-core/src/test/java/org/apache/activemq/usecases/ReliableReconnectTest.java b/activemq-core/src/test/java/org/apache/activemq/usecases/ReliableReconnectTest.java index 5aa16e56e5..9642730a83 100755 --- a/activemq-core/src/test/java/org/apache/activemq/usecases/ReliableReconnectTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/usecases/ReliableReconnectTest.java @@ -68,6 +68,12 @@ public class ReliableReconnectTest extends TestSupport { topic = true; destination = createDestination(getClass().getName()); } + + protected void tearDown() throws Exception { + if (broker!=null) { + broker.stop(); + } + } public ActiveMQConnectionFactory getConnectionFactory() throws Exception { String url = "failover://" + DEFAULT_BROKER_URL; @@ -77,6 +83,7 @@ public class ReliableReconnectTest extends TestSupport { protected void startBroker() throws JMSException { try { broker = BrokerFactory.createBroker(new URI("broker://()/localhost")); + broker.setUseShutdownHook(false); broker.addConnector(DEFAULT_BROKER_URL); broker.start(); } catch (Exception e) {