Do not raise exception for undelivered empty messages

Closes gh-23828
This commit is contained in:
Rossen Stoyanchev
2020-03-13 12:29:32 +00:00
parent 1a8caf9e2b
commit fa6ccc066d
2 changed files with 27 additions and 4 deletions

View File

@@ -380,10 +380,16 @@ public abstract class AbstractSockJsSession implements SockJsSession {
public void delegateMessages(String... messages) throws SockJsMessageDeliveryException {
for (int i = 0; i < messages.length; i++) {
try {
if (isClosed()) {
throw new SockJsMessageDeliveryException(this.id, getUndelivered(messages, i), "Session closed");
if (!isClosed()) {
this.handler.handleMessage(this, new TextMessage(messages[i]));
}
else {
List<String> undelivered = getUndelivered(messages, i);
if (undelivered.isEmpty()) {
return;
}
throw new SockJsMessageDeliveryException(this.id, undelivered, "Session closed");
}
this.handler.handleMessage(this, new TextMessage(messages[i]));
}
catch (Exception ex) {
throw new SockJsMessageDeliveryException(this.id, getUndelivered(messages, i), ex);