Repository: activemq-artemis Updated Branches: refs/heads/master 499273bd6 -> 7377ef7f6
ARTEMIS-1601 deal with race in Stomp sendMessage If the Stomp consumer was closed at or near the same time a message was dispatched then an NPE might result. Throwing an exception is a relatively expensive operation in the JVM because of the stacktrace information that needs to be generated, so in cases where it is known that a null value could be returned one should check and handle it appropriately. Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/b8f591b6 Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/b8f591b6 Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/b8f591b6 Branch: refs/heads/master Commit: b8f591b6b9b84cbea599db95c6b743a2c4088319 Parents: 499273b Author: jostbg <[email protected]> Authored: Thu Jan 11 12:16:35 2018 +0100 Committer: Justin Bertram <[email protected]> Committed: Thu Jan 11 11:42:56 2018 -0600 ---------------------------------------------------------------------- .../apache/activemq/artemis/core/protocol/stomp/StompSession.java | 3 +++ 1 file changed, 3 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b8f591b6/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompSession.java ---------------------------------------------------------------------- diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompSession.java b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompSession.java index 33f5c7a..e188e75 100644 --- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompSession.java +++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompSession.java @@ -138,6 +138,9 @@ public class StompSession implements SessionCallback { ICoreMessage newServerMessage = serverMessage.toCore(); try { StompSubscription subscription = subscriptions.get(consumer.getID()); + // subscription might be null if the consumer was closed + if (subscription == null) + return 0; StompFrame frame; ActiveMQBuffer buffer;
