The unit test was failing on slower hardware, some backups could be missed if the transport was processing the ConnectionControl command during the stop since the buildBackups method runs from there outside the reconnectMutex and not in the thread of the taskRunner. 

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1370559 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2012-08-07 22:02:28 +00:00
parent c7fcceac0e
commit 205d02598d
2 changed files with 18 additions and 13 deletions

View File

@ -355,15 +355,6 @@ public class FailoverTransport implements CompositeTransport {
started = false;
disposed = true;
connected = false;
for (BackupTransport backup : backups) {
backup.setDisposed(true);
Transport transport = backup.getTransport();
if (transport != null) {
transport.setTransportListener(disposedListener);
backupsToStop.add(transport);
}
}
backups.clear();
if (connectedTransport.get() != null) {
transportToStop = connectedTransport.getAndSet(null);
@ -374,15 +365,29 @@ public class FailoverTransport implements CompositeTransport {
sleepMutex.notifyAll();
}
reconnectTask.shutdown();
if (transportToStop != null) {
transportToStop.stop();
synchronized(backupMutex) {
for (BackupTransport backup : backups) {
backup.setDisposed(true);
Transport transport = backup.getTransport();
if (transport != null) {
transport.setTransportListener(disposedListener);
backupsToStop.add(transport);
}
}
backups.clear();
}
for (Transport transport : backupsToStop) {
try {
if (LOG.isTraceEnabled()) {
LOG.trace("Stopped backup: " + transport);
}
disposeTransport(transport);
} catch (Exception e) {
}
}
if (transportToStop != null) {
transportToStop.stop();
}
}
public long getInitialReconnectDelay() {

View File

@ -92,7 +92,7 @@ public class FailoverBackupLeakTest {
buildConnection(factory);
}
assertTrue(connectionProperties + " broker1 connection count not zero", Wait.waitFor(new Wait.Condition() {
assertTrue(connectionProperties + " broker1 connection count not zero: was["+getConnectionCount(s1)+"]", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
@ -100,7 +100,7 @@ public class FailoverBackupLeakTest {
}
}));
assertTrue(connectionProperties + " broker2 connection count not zero", Wait.waitFor(new Wait.Condition() {
assertTrue(connectionProperties + " broker2 connection count not zero: was["+getConnectionCount(s2)+"]", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {