From 3ad584eaef2e3eb0117ef8ba9378411bfacb9054 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 29 Jan 2019 10:45:54 +1100 Subject: [PATCH] Issue #3290 async onOpen, onClose and onError Changes after review: + failure to send abnormal close closes connection prior to failing callback. Signed-off-by: Greg Wilkins --- .../core/internal/WebSocketChannel.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketChannel.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketChannel.java index 7db48c1d95f..6e615b329dd 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketChannel.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/WebSocketChannel.java @@ -524,19 +524,22 @@ public class WebSocketChannel implements IncomingFrames, FrameHandler.CoreSessio } catch (Throwable ex) { - try + if (frame.getOpCode() == OpCode.CLOSE) { + CloseStatus closeStatus = CloseStatus.getCloseStatus(frame); + if (closeStatus instanceof AbnormalCloseStatus) + closeConnection(null, closeStatus, Callback.from( + ()->callback.failed(ex), + x2-> + { + ex.addSuppressed(x2); + callback.failed(ex); + })); + else + callback.failed(ex); + } + else callback.failed(ex); - } - finally - { - if (frame.getOpCode() == OpCode.CLOSE) - { - CloseStatus closeStatus = CloseStatus.getCloseStatus(frame); - if (closeStatus instanceof AbnormalCloseStatus) - closeConnection(null, closeStatus, NOOP); - } - } } }