From 7562d9bbf844bf927269541d4238002a3b9987f8 Mon Sep 17 00:00:00 2001 From: catbref Date: Tue, 1 Dec 2020 17:22:40 +0000 Subject: [PATCH] Fix potential NPE when closing a websocket that failed to open properly --- src/main/java/org/qortal/api/websocket/ApiWebSocket.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/qortal/api/websocket/ApiWebSocket.java b/src/main/java/org/qortal/api/websocket/ApiWebSocket.java index 87ee16cd..f6a439ea 100644 --- a/src/main/java/org/qortal/api/websocket/ApiWebSocket.java +++ b/src/main/java/org/qortal/api/websocket/ApiWebSocket.java @@ -107,7 +107,9 @@ abstract class ApiWebSocket extends WebSocketServlet { public void onWebSocketClose(Session session, int statusCode, String reason) { synchronized (SESSIONS_BY_CLASS) { - SESSIONS_BY_CLASS.get(this.getClass()).remove(session); + List sessions = SESSIONS_BY_CLASS.get(this.getClass()); + if (sessions != null) + sessions.remove(session); } }