activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject [13/18] git commit: https://issues.apache.org/jira/browse/AMQ-4897 - race condition in failover transport
Date Wed, 12 Mar 2014 17:06:52 GMT
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/f7e38f56
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/f7e38f56
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/f7e38f56

Branch: refs/heads/activemq-5.9
Commit: f7e38f56665f06e9f3892901184cc3b6b6aea278
Parents: dc308ab
Author: Dejan Bosanac <dejan@nighttale.net>
Authored: Tue Nov 19 12:41:10 2013 +0100
Committer: Hadrian Zbarcea <hadrian@apache.org>
Committed: Wed Mar 12 12:10:05 2014 -0400

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


http://git-wip-us.apache.org/repos/asf/activemq/blob/f7e38f56/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