This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.0.x by this push: new 180c955 Follow-up to fix for 65763. 180c955 is described below commit 180c955218eea4eda7e7281047ee5120ce772974 Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri Jan 7 23:24:09 2022 +0000 Follow-up to fix for 65763. Improving the handling of timeouts meant that code that was previously skipped due to an uncaught exception was no longer skipped and that broke some tests. Ensure close message and/or notifications are only sent once. --- java/org/apache/tomcat/websocket/WsSession.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/java/org/apache/tomcat/websocket/WsSession.java b/java/org/apache/tomcat/websocket/WsSession.java index a2e8768..8766d46 100644 --- a/java/org/apache/tomcat/websocket/WsSession.java +++ b/java/org/apache/tomcat/websocket/WsSession.java @@ -692,6 +692,8 @@ public class WsSession implements Session { if (log.isDebugEnabled()) { log.debug(sm.getString("wsSession.doClose", id)); } + + // This will trigger a flush of any batched messages. try { wsRemoteEndpoint.setBatchingAllowed(false); } catch (IOException e) { @@ -699,13 +701,20 @@ public class WsSession implements Session { fireEndpointOnError(e); } - state = State.OUTPUT_CLOSED; + /* + * If the flush above fails the error handling could call this + * method recursively. Without this check, the close message and + * notifications could be sent multiple times. + */ + if (state != State.OUTPUT_CLOSED) { + state = State.OUTPUT_CLOSED; - sendCloseMessage(closeReasonMessage); - if (closeSocket) { - wsRemoteEndpoint.close(); + sendCloseMessage(closeReasonMessage); + if (closeSocket) { + wsRemoteEndpoint.close(); + } + fireEndpointOnClose(closeReasonLocal); } - fireEndpointOnClose(closeReasonLocal); } IOException ioe = new IOException(sm.getString("wsSession.messageFailed")); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org