Publish events only after successful channel send
The StompSubProtcolHandler now checks the outcome of the send to the inbound client channel. If the message was prevented from being sent, e.g. as part of authorization, events are not published Issue: SPR-13339
This commit is contained in:
@@ -277,7 +277,9 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
|
||||
|
||||
try {
|
||||
SimpAttributesContextHolder.setAttributesFromMessage(message);
|
||||
if (this.eventPublisher != null) {
|
||||
boolean sent = outputChannel.send(message);
|
||||
|
||||
if (sent && this.eventPublisher != null) {
|
||||
if (StompCommand.CONNECT.equals(headerAccessor.getCommand())) {
|
||||
publishEvent(new SessionConnectEvent(this, message, user));
|
||||
}
|
||||
@@ -288,7 +290,6 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
|
||||
publishEvent(new SessionUnsubscribeEvent(this, message, user));
|
||||
}
|
||||
}
|
||||
outputChannel.send(message);
|
||||
}
|
||||
finally {
|
||||
SimpAttributesContextHolder.resetAttributes();
|
||||
|
||||
Reference in New Issue
Block a user