You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ma...@apache.org on 2026/10/06 13:50:11 UTC

(activemq) branch main updated: Fix flaky ExceptionListenerTest: wait for transport-failed before createSession (#2544)

This is an automated email from the ASF dual-hosted git repository.

mattrpav pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq.git


The following commit(s) were added to refs/heads/main by this push:
     new 9625eb588a Fix flaky ExceptionListenerTest: wait for transport-failed before createSession (#2544)
9625eb588a is described below

commit 9625eb588aaa5d746d0806e6719f7701462ce096
Author: Matt Pavlovich <ma...@apache.org>
AuthorDate: Tue Oct 6 08:50:04 2026 -0500

    Fix flaky ExceptionListenerTest: wait for transport-failed before createSession (#2544)
    
    The security exception fires the ExceptionListener and marks the transport
    failed on two separate async tasks in ActiveMQConnection.onException. Waiting
    only for the listener let createSession race a disposing transport and get
    JMSException("Stopped.") instead of the expected ConnectionFailedException.
---
 .../org/apache/activemq/usecases/ExceptionListenerTest.java    | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ExceptionListenerTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ExceptionListenerTest.java
index b1c9958368..ea07294443 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ExceptionListenerTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ExceptionListenerTest.java
@@ -24,6 +24,7 @@ import jakarta.jms.ExceptionListener;
 import jakarta.jms.JMSException;
 import jakarta.jms.JMSSecurityException;
 import jakarta.jms.Session;
+import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.ConnectionFailedException;
 import org.apache.activemq.broker.BrokerPlugin;
@@ -107,6 +108,15 @@ public class ExceptionListenerTest implements ExceptionListener {
 
         assertTrue("expected exception: " + expected, expected.getCause().getCause() instanceof SecurityException);
 
+        // ActiveMQConnection.onException delivers the security failure to the
+        // ExceptionListener and marks the transport failed on two independent
+        // async tasks. The listener firing above does not guarantee the transport
+        // is failed yet, so wait for the failed state; otherwise createSession can
+        // race a mid-dispose transport and see JMSException("Stopped.") instead of
+        // the expected ConnectionFailedException.
+        final ActiveMQConnection amqConnection = (ActiveMQConnection) connection;
+        assertTrue(Wait.waitFor((Wait.Condition) amqConnection::isTransportFailed, 5000, 10));
+
         try {
             connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
             fail("Expect error b/c connection is auto closed on security exception above");


---------------------------------------------------------------------
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