From 0028b8d13c63054cf84c57f8a810f4fd9824329e Mon Sep 17 00:00:00 2001 From: Christian Kittel Date: Sun, 6 Feb 2022 15:43:00 +0100 Subject: [PATCH] Prevent Null Pointer Exception if socket connection is broken (#12223) Signed-off-by: EvilPingu --- .../deconz/internal/netutils/WebSocketConnection.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/netutils/WebSocketConnection.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/netutils/WebSocketConnection.java index 4caf030b3..9fcbd7151 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/netutils/WebSocketConnection.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/netutils/WebSocketConnection.java @@ -158,7 +158,12 @@ public class WebSocketConnection { @SuppressWarnings("unused") @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)) { handleWrongSession(session, "Connection error: " + cause.getMessage()); return;