try and ensure that the brokers shutdown cleanly for the

ReliableReconnectTest - as it can hang

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@603952 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2007-12-13 16:52:27 +00:00
parent 0ac3f165dc
commit 225d2bf055
3 changed files with 12 additions and 1 deletions

View File

@ -108,6 +108,7 @@ public class KahaStore implements Store {
closed = true; closed = true;
if (initialized) { if (initialized) {
unlock(); unlock();
lockFile.close();
for (ListContainerImpl container : lists.values()) { for (ListContainerImpl container : lists.values()) {
container.close(); container.close();

View File

@ -253,11 +253,11 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
if (!started.compareAndSet(true, false)) { if (!started.compareAndSet(true, false)) {
return; return;
} }
unlock();
if (lockFile != null) { if (lockFile != null) {
lockFile.close(); lockFile.close();
lockFile = null; lockFile = null;
} }
unlock();
this.usageManager.getMemoryUsage().removeUsageListener(this); this.usageManager.getMemoryUsage().removeUsageListener(this);
synchronized (this) { synchronized (this) {
Scheduler.cancel(periodicCheckpointTask); Scheduler.cancel(periodicCheckpointTask);
@ -890,9 +890,12 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
if (!disableLocking && (null != lock)) { if (!disableLocking && (null != lock)) {
//clear property doesn't work on some platforms //clear property doesn't work on some platforms
System.getProperties().remove(getPropertyKey()); System.getProperties().remove(getPropertyKey());
System.clearProperty(getPropertyKey());
assert(System.getProperty(getPropertyKey())==null);
if (lock.isValid()) { if (lock.isValid()) {
lock.release(); lock.release();
lock.channel().close(); lock.channel().close();
} }
lock = null; lock = null;
} }

View File

@ -68,6 +68,12 @@ public class ReliableReconnectTest extends TestSupport {
topic = true; topic = true;
destination = createDestination(getClass().getName()); destination = createDestination(getClass().getName());
} }
protected void tearDown() throws Exception {
if (broker!=null) {
broker.stop();
}
}
public ActiveMQConnectionFactory getConnectionFactory() throws Exception { public ActiveMQConnectionFactory getConnectionFactory() throws Exception {
String url = "failover://" + DEFAULT_BROKER_URL; String url = "failover://" + DEFAULT_BROKER_URL;
@ -77,6 +83,7 @@ public class ReliableReconnectTest extends TestSupport {
protected void startBroker() throws JMSException { protected void startBroker() throws JMSException {
try { try {
broker = BrokerFactory.createBroker(new URI("broker://()/localhost")); broker = BrokerFactory.createBroker(new URI("broker://()/localhost"));
broker.setUseShutdownHook(false);
broker.addConnector(DEFAULT_BROKER_URL); broker.addConnector(DEFAULT_BROKER_URL);
broker.start(); broker.start();
} catch (Exception e) { } catch (Exception e) {