Skip to content

Commit

Permalink
Improve setting of WebSocket error status
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianKirmaier authored and rstoyanchev committed Jul 29, 2022
1 parent 6e6f863 commit b6144e5
Showing 1 changed file with 7 additions and 1 deletion.
Expand Up @@ -33,6 +33,7 @@
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;
Expand Down Expand Up @@ -247,7 +248,12 @@ public void onError(Throwable ex) {
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
Expand Down

0 comments on commit b6144e5

Please sign in to comment.