activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject git commit: https://issues.apache.org/jira/browse/AMQ-5396
Date Mon, 20 Oct 2014 23:06:31 GMT
Repository: activemq
Updated Branches:
  refs/heads/trunk 6885ff0a6 -> 3873ecfe5


https://issues.apache.org/jira/browse/AMQ-5396

Reviewed the patch and it looks good, I made a small change to prevent
logging in the case where no old context exists so we don't spam the
logs.  

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

Branch: refs/heads/trunk
Commit: 3873ecfe5dc213949a6bb3d7a58f36bd612d19ec
Parents: 6885ff0
Author: Timothy Bish <tabish121@gmail.com>
Authored: Mon Oct 20 19:06:21 2014 -0400
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Mon Oct 20 19:06:21 2014 -0400

----------------------------------------------------------------------
 .../activemq/broker/region/RegionBroker.java    | 35 +++++++++++---------
 1 file changed, 20 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/3873ecfe/activemq-broker/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
index 4ebcef5..cb79c84 100755
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
@@ -242,23 +242,14 @@ public class RegionBroker extends EmptyBroker {
         if (clientId == null) {
             throw new InvalidClientIDException("No clientID specified for connection request");
         }
+
+        ConnectionContext oldContext = null;
+
         synchronized (clientIdSet) {
-            ConnectionContext oldContext = clientIdSet.get(clientId);
+            oldContext = clientIdSet.get(clientId);
             if (oldContext != null) {
                 if (context.isAllowLinkStealing()) {
                     clientIdSet.put(clientId, context);
-                    if (oldContext.getConnection() != null) {
-                        Connection connection = oldContext.getConnection();
-                        LOG.warn("Stealing link for clientId {} From Connection {}", clientId,
oldContext.getConnection());
-                        if (connection instanceof TransportConnection) {
-                            TransportConnection transportConnection = (TransportConnection)
connection;
-                            transportConnection.stopAsync();
-                        } else {
-                            connection.stop();
-                        }
-                    } else {
-                        LOG.error("No Connection found for {}", oldContext);
-                    }
                 } else {
                     throw new InvalidClientIDException("Broker: " + getBrokerName() + " -
Client: " + clientId + " already connected from "
                         + oldContext.getConnection().getRemoteAddress());
@@ -268,6 +259,21 @@ public class RegionBroker extends EmptyBroker {
             }
         }
 
+        if (oldContext != null) {
+            if (oldContext.getConnection() != null) {
+                Connection connection = oldContext.getConnection();
+                LOG.warn("Stealing link for clientId {} From Connection {}", clientId, oldContext.getConnection());
+                if (connection instanceof TransportConnection) {
+                    TransportConnection transportConnection = (TransportConnection) connection;
+                    transportConnection.stopAsync();
+                } else {
+                    connection.stop();
+                }
+            } else {
+                LOG.error("No Connection found for {}", oldContext);
+            }
+        }
+
         connections.add(context.getConnection());
     }
 
@@ -279,8 +285,7 @@ public class RegionBroker extends EmptyBroker {
         }
         synchronized (clientIdSet) {
             ConnectionContext oldValue = clientIdSet.get(clientId);
-            // we may be removing the duplicate connection, not the first
-            // connection to be created
+            // we may be removing the duplicate connection, not the first connection to be
created
             // so lets check that their connection IDs are the same
             if (oldValue == context) {
                 if (isEqual(oldValue.getConnectionId(), info.getConnectionId())) {


Mime
View raw message