You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cs...@apache.org on 2026/06/08 14:23:01 UTC
(activemq) branch activemq-5.19.x updated: Ensure at most one BrokerInfo command is received (#2083) (#2087)
This is an automated email from the ASF dual-hosted git repository.
cshannon pushed a commit to branch activemq-5.19.x
in repository https://gitbox.apache.org/repos/asf/activemq.git
The following commit(s) were added to refs/heads/activemq-5.19.x by this push:
new 685ab0b7a4 Ensure at most one BrokerInfo command is received (#2083) (#2087)
685ab0b7a4 is described below
commit 685ab0b7a4618abd25be7d64c3355401581b69e5
Author: Christopher L. Shannon <cs...@apache.org>
AuthorDate: Mon Jun 8 10:21:52 2026 -0400
Ensure at most one BrokerInfo command is received (#2083) (#2087)
There should only ever be at most one BrokerInfo command received on a
connection so we should throw an exception and close the connection if a
second is receveived as that is a protocol error.
(cherry picked from commit 80562ea8d327b7f538de1ff7672f158fe2abc4c1)
---
.../apache/activemq/broker/TransportConnection.java | 13 ++++++++-----
.../network/DurableSyncNetworkBridgeAuthTest.java | 18 ++++++++++++++++++
2 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java b/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java
index 2ede7a547d..9f44caab2c 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java
@@ -1389,7 +1389,14 @@ public class TransportConnection implements Connection, Task, CommandVisitor {
}
@Override
- public Response processBrokerInfo(BrokerInfo info) {
+ public Response processBrokerInfo(BrokerInfo info) throws IOException {
+ // We only expect to get at most one broker info command per connection
+ // Log and throw an IOException to close the connection if we receive more
+ // one because this is a protocol violation
+ if (this.brokerInfo != null) {
+ LOG.warn("Unexpected extra broker info command received: {}", info);
+ throw new IOException("Unexpected extra broker info command received from: " + info.getBrokerId());
+ }
if (info.isSlaveBroker()) {
LOG.error(" Slave Brokers are no longer supported - slave trying to attach is: {}", info.getBrokerName());
} else if (info.isNetworkConnection() && !info.isDuplexConnection()) {
@@ -1462,10 +1469,6 @@ public class TransportConnection implements Connection, Task, CommandVisitor {
return null;
}
}
- // We only expect to get one broker info command per connection
- if (this.brokerInfo != null) {
- LOG.warn("Unexpected extra broker info command received: {}", info);
- }
this.brokerInfo = info;
networkConnection = true;
List<TransportConnectionState> connectionStates = listConnectionStates();
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/network/DurableSyncNetworkBridgeAuthTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/network/DurableSyncNetworkBridgeAuthTest.java
index 646dd4f184..19c95da29b 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/network/DurableSyncNetworkBridgeAuthTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/network/DurableSyncNetworkBridgeAuthTest.java
@@ -30,6 +30,7 @@ import org.apache.activemq.broker.BrokerPlugin;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.TransportConnector;
import org.apache.activemq.command.ActiveMQTopic;
+import org.apache.activemq.command.BrokerInfo;
import org.apache.activemq.command.BrokerSubscriptionInfo;
import org.apache.activemq.command.DiscoveryEvent;
import org.apache.activemq.security.AuthenticationUser;
@@ -152,6 +153,23 @@ public class DurableSyncNetworkBridgeAuthTest extends AbstractDurableSyncNetwork
assertTrue(Wait.waitFor(() -> brokerSubInfo.get() != null,5000,10));
}
+ @Test
+ public void testDuplicateBrokerInfo() throws Exception {
+ // Wait for connection and auth setup
+ doSetUp(true, true, tempFolder.newFolder(), tempFolder.newFolder(),
+ TimeUnit.SECONDS.toMillis(15));
+ assertTrue(Wait.waitFor(() -> brokerSubInfo.get() != null,5000,10));
+
+ // find the established bridge
+ DemandForwardingBridge bridge = (DemandForwardingBridge) localBroker.getNetworkConnectors().get(0).activeBridges().stream()
+ .findFirst().orElseThrow();
+
+ // send to one of the brokers (networked brokers will have already received a BrokerInfo)
+ // the duplicate will trigger the bridge connection to close
+ bridge.localBroker.oneway(new BrokerInfo());
+ assertTrue(Wait.waitFor(bridge.localBroker::isDisposed,5000,10));
+ }
+
protected void doSetUp(boolean deleteAllMessages, boolean startNetworkConnector, File localDataDir,
File remoteDataDir, long waitForStart) throws Exception {
doSetUpRemoteBroker(deleteAllMessages, remoteDataDir, 0);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@activemq.apache.org
For additional commands, e-mail: commits-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact