AMQ-4044: Fixed issue with double stopping BrokerService.

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1384691 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Claus Ibsen 2012-09-14 09:13:51 +00:00
parent d4ee73fe10
commit 4260034561
1 changed files with 5 additions and 2 deletions

View File

@ -186,6 +186,7 @@ public class BrokerService implements Service {
private PolicyMap destinationPolicy;
private final AtomicBoolean started = new AtomicBoolean(false);
private final AtomicBoolean stopped = new AtomicBoolean(false);
private final AtomicBoolean stopping = new AtomicBoolean(false);
private BrokerPlugin[] plugins;
private boolean keepDurableSubsActive = true;
private boolean useVirtualTopics = true;
@ -549,6 +550,7 @@ public class BrokerService implements Service {
return;
}
stopping.set(false);
startDate = new Date();
MDC.put("activemq.broker", brokerName);
@ -700,7 +702,8 @@ public class BrokerService implements Service {
*/
@PreDestroy
public void stop() throws Exception {
if (!started.get()) {
if (!stopping.compareAndSet(false, true)) {
LOG.trace("Broker already stopping/stopped");
return;
}
@ -795,7 +798,7 @@ public class BrokerService implements Service {
LOG.info("Uptime {}", getUptime());
}
LOG.info("ActiveMQ " + getBrokerVersion() + " JMS Message Broker ("
+ getBrokerName() + ", " + brokerId + ") stopped");
+ getBrokerName() + ", " + brokerId + ") is shutdown");
}
synchronized (shutdownHooks) {