]> git.basschouten.com Git - openhab-addons.git/commitdiff
Prevent Null Pointer Exception if socket connection is broken (#12223)
authorChristian Kittel <EvilPingu@users.noreply.github.com>
Sun, 6 Feb 2022 14:43:00 +0000 (15:43 +0100)
committerGitHub <noreply@github.com>
Sun, 6 Feb 2022 14:43:00 +0000 (15:43 +0100)
Signed-off-by: EvilPingu <ckittel@gmx.de>
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/netutils/WebSocketConnection.java

index 4caf030b39f37ba278c33f5e3dc04fc750527d6d..9fcbd7151574a0acf0cd16c77a888b3342c691f3 100644 (file)
@@ -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;