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

tabish 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 e49cda58ad ARTEMIS-5598 mitigate race condition on ServerConsumer 
callback
e49cda58ad is described below

commit e49cda58ad4ae5f07bf103c31b46005756c3b36d
Author: Justin Bertram <[email protected]>
AuthorDate: Tue Jul 29 15:25:17 2025 -0500

    ARTEMIS-5598 mitigate race condition on ServerConsumer callback
    
    No test here as the cause of & solution for the NPE is determined by
    static analysis.
---
 .../activemq/artemis/core/server/impl/ServerConsumerImpl.java     | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
index 40fe9d730b..167d9986aa 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
@@ -526,7 +526,13 @@ public class ServerConsumerImpl implements ServerConsumer, 
ReadyListener {
          }
       } finally {
          pendingDelivery.countDown();
-         callback.afterDelivery();
+
+         // ensure the callback is still valid without blocking other threads
+         final SessionCallback localCallback = callback;
+         if (localCallback != null) {
+            localCallback.afterDelivery();
+         }
+
          if (server.hasBrokerMessagePlugins()) {
             server.callBrokerMessagePlugins(plugin -> 
plugin.afterDeliver(this, reference));
          }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to