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.
This commit is contained in:
jostbg 2018-01-11 12:16:35 +01:00 committed by Justin Bertram
parent 499273bd68
commit b8f591b6b9
1 changed files with 3 additions and 0 deletions

View File

@ -138,6 +138,9 @@ public class StompSession implements SessionCallback {
ICoreMessage newServerMessage = serverMessage.toCore(); ICoreMessage newServerMessage = serverMessage.toCore();
try { try {
StompSubscription subscription = subscriptions.get(consumer.getID()); StompSubscription subscription = subscriptions.get(consumer.getID());
// subscription might be null if the consumer was closed
if (subscription == null)
return 0;
StompFrame frame; StompFrame frame;
ActiveMQBuffer buffer; ActiveMQBuffer buffer;