fix for VMTransportWaitForTest test, prevent broker from being started twice

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1425904 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bosanac Dejan 2012-12-26 13:36:59 +00:00
parent 4724913279
commit 428a0631d3
2 changed files with 3 additions and 3 deletions

View File

@ -471,7 +471,7 @@ public class BrokerService implements Service {
}
public boolean isStarted() {
return started.get();
return started.get() && startedLatch.getCount() == 0;
}
/**
@ -868,7 +868,7 @@ public class BrokerService implements Service {
*/
public boolean waitUntilStarted() {
boolean waitSucceeded = false;
while (isStarted() && !stopped.get() && !waitSucceeded) {
while (!isStarted() && !stopped.get() && !waitSucceeded) {
try {
if (startException != null) {
return waitSucceeded;

View File

@ -182,7 +182,7 @@ public class VMTransportFactory extends TransportFactory {
broker = registry.lookup(brokerName);
if (broker == null && waitForStart > 0) {
final long expiry = System.currentTimeMillis() + waitForStart;
while (broker == null && expiry > System.currentTimeMillis()) {
while ((broker == null || !broker.isStarted()) && expiry > System.currentTimeMillis()) {
long timeout = Math.max(0, expiry - System.currentTimeMillis());
try {
LOG.debug("waiting for broker named: " + brokerName + " to start");