From 3b9008bda008ee8e7413c05c5c6238503d9a3bcc Mon Sep 17 00:00:00 2001 From: Markus Meierhofer Date: Thu, 11 Mar 2021 11:35:19 +0100 Subject: [PATCH] ARTEMIS-3174: Set new connection on ServerSession during reattachment During session reattachment, also set the new connection on the "session" member of the ServerSessionPacketHandler. Until now, the connected ServerSessionImpl instance still referenced the old connection although it had already been transferred on the new connection. --- .../core/protocol/core/ServerSessionPacketHandler.java | 2 ++ .../apache/activemq/artemis/core/server/ServerSession.java | 2 ++ .../artemis/core/server/impl/ServerSessionImpl.java | 7 ++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java index 5ec11c577c..d3b19090bd 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java @@ -1018,6 +1018,8 @@ public class ServerSessionPacketHandler implements ChannelHandler { newConnection.syncIDGeneratorSequence(remotingConnection.getIDGeneratorSequence()); + session.transferConnection(newConnection); + Connection oldTransportConnection = remotingConnection.getTransportConnection(); remotingConnection = newConnection; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java index b319cda5d3..9be941200f 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java @@ -58,6 +58,8 @@ public interface ServerSession extends SecurityAuth { @Override RemotingConnection getRemotingConnection(); + void transferConnection(RemotingConnection newConnection); + Transaction newTransaction(); boolean removeConsumer(long consumerID) throws Exception; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java index dbc68f23ca..05d9eb800f 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java @@ -136,7 +136,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { protected final boolean strictUpdateDeliveryCount; - protected final RemotingConnection remotingConnection; + protected RemotingConnection remotingConnection; protected final Map consumers = new ConcurrentHashMap<>(); @@ -1073,6 +1073,11 @@ public class ServerSessionImpl implements ServerSession, FailureListener { return remotingConnection; } + @Override + public void transferConnection(RemotingConnection newConnection) { + remotingConnection = newConnection; + } + @Override public String getSecurityDomain() { return securityDomain;