Prevent Null Pointer Exception if socket connection is broken (#12223)

Signed-off-by: EvilPingu <ckittel@gmx.de>
This commit is contained in:
Christian Kittel 2022-02-06 15:43:00 +01:00 committed by GitHub
parent 19fd145368
commit 0028b8d13c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -158,7 +158,12 @@ public class WebSocketConnection {
@SuppressWarnings("unused") @SuppressWarnings("unused")
@OnWebSocketError @OnWebSocketError
public void onError(Session session, Throwable cause) { public void onError(@Nullable Session session, Throwable cause) {
if (session == null) {
logger.trace("Encountered an error while processing on error without session. Connection state is {}: {}",
connectionState, cause.getMessage());
return;
}
if (!session.equals(this.session)) { if (!session.equals(this.session)) {
handleWrongSession(session, "Connection error: " + cause.getMessage()); handleWrongSession(session, "Connection error: " + cause.getMessage());
return; return;