This is an automated email from the ASF dual-hosted git repository.
robbie pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
The following commit(s) were added to refs/heads/main by this push:
new 9650984899 ARTEMIS-5697: also close proton transport upon sasl outcome
failure
9650984899 is described below
commit 965098489953c10d51cfa70f2ee66cb31d7668ad
Author: Robbie Gemmell <[email protected]>
AuthorDate: Thu Oct 9 13:03:03 2025 +0100
ARTEMIS-5697: also close proton transport upon sasl outcome failure
---
.../amqp/proton/handler/ProtonHandler.java | 2 ++
.../amqp/connect/AMQPConnectSaslTest.java | 31 ++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git
a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
index 6dd15858f3..7f06b6ffc6 100644
---
a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
+++
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
@@ -490,6 +490,8 @@ public class ProtonHandler extends ProtonInitializable
implements SaslListener {
switch (sasl.getState()) {
case PN_SASL_FAIL:
logger.info("Outbound connection failed, authentication failure");
+ sasl.setListener(null);
+ transport.close_head();
dispatchAuthFailed();
break;
case PN_SASL_PASS:
diff --git
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/AMQPConnectSaslTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/AMQPConnectSaslTest.java
index 7bfefa2b18..bbaf191f91 100644
---
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/AMQPConnectSaslTest.java
+++
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/AMQPConnectSaslTest.java
@@ -116,6 +116,37 @@ public class AMQPConnectSaslTest extends
AmqpClientTestSupport {
}
}
+ @Test
+ @Timeout(20)
+ public void testReconnectAfterSaslFailure() throws Exception {
+ try (ProtonTestServer peer = new ProtonTestServer()) {
+ // First attempt, refuse
+
peer.expectFailingSASLPlainConnect(SaslCode.SYS_TEMP.getValue().byteValue(),
PLAIN, ANONYMOUS);
+ peer.expectConnectionToDrop();
+
+ // Second attempt, succeeds
+ peer.expectSASLPlainConnect(USER, PASSWD, PLAIN, ANONYMOUS);
+ peer.expectOpen().respond();
+ peer.expectBegin().respond();
+ peer.start();
+
+ final URI remoteURI = peer.getServerURI();
+ logger.debug("Connect test started, peer listening on: {}",
remoteURI);
+
+ AMQPBrokerConnectConfiguration amqpConnection =
+ new AMQPBrokerConnectConfiguration(getTestName(),
"tcp://localhost:" + remoteURI.getPort());
+ amqpConnection.setReconnectAttempts(1); // Allow 1 reconnect
+ amqpConnection.setRetryInterval(200);
+ amqpConnection.setUser(USER);
+ amqpConnection.setPassword(PASSWD);
+
+ server.getConfiguration().addAMQPConnection(amqpConnection);
+ server.start();
+
+ peer.waitForScriptToComplete(5, TimeUnit.SECONDS);
+ }
+ }
+
@Test
@Timeout(20)
public void testConnectsWithXOauth2() throws Exception {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact