From 1e0c0b42ab187c16efcf17672383ac55b9ccad2b Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Wed, 24 Jan 2024 11:57:34 +1100 Subject: [PATCH 1/2] ensure callback is always completed in WebSocketCoreSession Signed-off-by: Lachlan Roberts --- .../jetty/websocket/core/WebSocketCoreSession.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/jetty-core/jetty-websocket/jetty-websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/WebSocketCoreSession.java b/jetty-core/jetty-websocket/jetty-websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/WebSocketCoreSession.java index 32102dd7f6ba..433195736326 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/WebSocketCoreSession.java +++ b/jetty-core/jetty-websocket/jetty-websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/WebSocketCoreSession.java @@ -351,11 +351,21 @@ else if (behavior == Behavior.CLIENT) CloseStatus closeStatus = new CloseStatus(code, cause); if (CloseStatus.isTransmittableStatusCode(code)) + { close(closeStatus, callback); + } else { if (sessionState.onClosed(closeStatus)) + { closeConnection(closeStatus, callback); + } + else + { + // We are already closed because of a previous failure. + // Succeed because failing might re-enter this branch if it's the Frame callback. + callback.succeeded(); + } } } From 6b20ee07536dc7ef3e749b1e6616ab4192a760d2 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Wed, 24 Jan 2024 12:00:46 +1100 Subject: [PATCH 2/2] ensure callback is always completed in WebSocketCoreSession Signed-off-by: Lachlan Roberts --- .../jetty/websocket/core/WebSocketCoreSession.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/jetty-core/jetty-websocket/jetty-websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/WebSocketCoreSession.java b/jetty-core/jetty-websocket/jetty-websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/WebSocketCoreSession.java index 433195736326..835fe66f66ca 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/WebSocketCoreSession.java +++ b/jetty-core/jetty-websocket/jetty-websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/WebSocketCoreSession.java @@ -317,11 +317,21 @@ else if (cause instanceof WebSocketTimeoutException || cause instanceof TimeoutE CloseStatus closeStatus = new CloseStatus(code, cause); if (CloseStatus.isTransmittableStatusCode(code)) + { close(closeStatus, callback); + } else { if (sessionState.onClosed(closeStatus)) + { closeConnection(closeStatus, callback); + } + else + { + // We are already closed because of a previous failure. + // Succeed because failing might re-enter this branch if it's the Frame callback. + callback.succeeded(); + } } }