You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2012/08/08 00:02:28 UTC
svn commit: r1370559 - in /activemq/trunk/activemq-core/src:
main/java/org/apache/activemq/transport/failover/FailoverTransport.java
test/java/org/apache/activemq/transport/failover/FailoverBackupLeakTest.java
Author: tabish
Date: Tue Aug 7 22:02:28 2012
New Revision: 1370559
URL: http://svn.apache.org/viewvc?rev=1370559&view=rev
Log:
Refine the fix for: https://issues.apache.org/jira/browse/AMQ-3939
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.
Modified:
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverBackupLeakTest.java
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java?rev=1370559&r1=1370558&r2=1370559&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java Tue Aug 7 22:02:28 2012
@@ -355,15 +355,6 @@ public class FailoverTransport implement
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 implement
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() {
Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverBackupLeakTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverBackupLeakTest.java?rev=1370559&r1=1370558&r2=1370559&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverBackupLeakTest.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverBackupLeakTest.java Tue Aug 7 22:02:28 2012
@@ -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 {