File tree Expand file tree Collapse file tree
activemq-client/src/main/java/org/apache/activemq Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2046,8 +2046,21 @@ public void onAsyncException(Throwable error) {
20462046
20472047 @ Override
20482048 public void onException (final IOException error ) {
2049- onAsyncException (error );
2049+ // Combine JMS ExceptionListener and TransportListener notifications
2050+ // into a single async task to prevent a race condition where the
2051+ // ExceptionListener (e.g. ConnectionPool) closes the connection and
2052+ // shuts down the executor before the TransportListener task is queued.
20502053 executeAsync (() -> {
2054+ // Notify JMS ExceptionListener first (same as onAsyncException)
2055+ if (exceptionListener != null ) {
2056+ try {
2057+ final JMSException jmsError = JMSExceptionSupport .create (error );
2058+ exceptionListener .onException (jmsError );
2059+ } catch (final Exception e ) {
2060+ LOG .debug ("Exception during JMS ExceptionListener notification" , e );
2061+ }
2062+ }
2063+
20512064 transportFailed (error );
20522065 ServiceSupport .dispose (ActiveMQConnection .this .transport );
20532066 brokerInfoReceived .countDown ();
You can’t perform that action at this time.
0 commit comments