Skip to content

Commit e49cda5

Browse files
jbertramtabish121
authored andcommitted
ARTEMIS-5598 mitigate race condition on ServerConsumer callback
No test here as the cause of & solution for the NPE is determined by static analysis.
1 parent e6775d7 commit e49cda5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,13 @@ public void proceedDeliver(MessageReference reference) throws Exception {
526526
}
527527
} finally {
528528
pendingDelivery.countDown();
529-
callback.afterDelivery();
529+
530+
// ensure the callback is still valid without blocking other threads
531+
final SessionCallback localCallback = callback;
532+
if (localCallback != null) {
533+
localCallback.afterDelivery();
534+
}
535+
530536
if (server.hasBrokerMessagePlugins()) {
531537
server.callBrokerMessagePlugins(plugin -> plugin.afterDeliver(this, reference));
532538
}

0 commit comments

Comments
 (0)