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:
parent
499273bd68
commit
b8f591b6b9
|
@ -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;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue