Improve setting of WebSocket error status
See gh-28836
This commit is contained in:
committed by
Rossen Stoyanchev
parent
6e6f8637d1
commit
b6144e5682
@@ -33,6 +33,7 @@ import org.springframework.http.server.reactive.AbstractListenerReadPublisher;
|
||||
import org.springframework.http.server.reactive.AbstractListenerWriteProcessor;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.reactive.socket.CloseStatus;
|
||||
import org.springframework.web.reactive.socket.HandshakeInfo;
|
||||
import org.springframework.web.reactive.socket.WebSocketHandler;
|
||||
@@ -247,7 +248,12 @@ public abstract class AbstractListenerWebSocketSession<T> extends AbstractWebSoc
|
||||
if (this.handlerCompletionMono != null) {
|
||||
this.handlerCompletionMono.onError(ex);
|
||||
}
|
||||
close(CloseStatus.SERVER_ERROR.withReason(ex.getMessage()));
|
||||
if(!StringUtils.hasText(ex.getMessage())) {
|
||||
close(CloseStatus.SERVER_ERROR);
|
||||
}
|
||||
else {
|
||||
close(CloseStatus.SERVER_ERROR.withReason(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user