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 2014/10/21 01:06:31 UTC
git commit: https://issues.apache.org/jira/browse/AMQ-5396
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 <ta...@gmail.com>
Authored: Mon Oct 20 19:06:21 2014 -0400
Committer: Timothy Bish <ta...@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())) {