activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject git commit: https://issues.apache.org/jira/browse/AMQ-4897 - race condition in failover transport
Date Tue, 19 Nov 2013 11:41:30 GMT
Updated Branches:
  refs/heads/trunk bc4f4e92a -> bc1ca6c8c


https://issues.apache.org/jira/browse/AMQ-4897 - race condition in failover transport


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/bc1ca6c8
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/bc1ca6c8
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/bc1ca6c8

Branch: refs/heads/trunk
Commit: bc1ca6c8cf3cfb36f552c6315f1a2ec359e3bb6b
Parents: bc4f4e9
Author: Dejan Bosanac <dejan@nighttale.net>
Authored: Tue Nov 19 12:41:10 2013 +0100
Committer: Dejan Bosanac <dejan@nighttale.net>
Committed: Tue Nov 19 12:41:10 2013 +0100

----------------------------------------------------------------------
 .../transport/failover/FailoverTransport.java   | 25 +++++++++-----------
 1 file changed, 11 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/bc1ca6c8/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
b/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
index 541eaeb..955a190 100755
--- a/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
+++ b/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
@@ -241,27 +241,24 @@ public class FailoverTransport implements CompositeTransport {
     }
 
     public final void handleTransportFailure(IOException e) throws InterruptedException {
-        if (LOG.isTraceEnabled()) {
-            LOG.trace(this + " handleTransportFailure: " + e);
-        }
-        Transport transport = connectedTransport.getAndSet(null);
-        if (transport == null) {
-            // sync with possible in progress reconnect
-            synchronized (reconnectMutex) {
-                transport = connectedTransport.getAndSet(null);
+        synchronized (reconnectMutex) {
+            if (LOG.isTraceEnabled()) {
+                LOG.trace(this + " handleTransportFailure: " + e);
             }
-        }
-        if (transport != null) {
 
-            disposeTransport(transport);
+            Transport transport = connectedTransport.getAndSet(null);
+
+            if (transport != null) {
+
+                disposeTransport(transport);
+
+                boolean reconnectOk = false;
 
-            boolean reconnectOk = false;
-            synchronized (reconnectMutex) {
                 if (canReconnect()) {
                     reconnectOk = true;
                 }
                 LOG.warn("Transport (" + transport.getRemoteAddress() + ") failed, reason:
 " + e
-                        + (reconnectOk ? "," : ", not")  +" attempting to automatically reconnect");
+                        + (reconnectOk ? "," : ", not") + " attempting to automatically reconnect");
 
                 initialized = false;
                 failedConnectTransportURI = connectedTransportURI;


Mime
View raw message