This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push: new d8aae3a Ensure WebSocket connection write lock is released on exception d8aae3a is described below commit d8aae3ac3ae991d5d4e7bd052b9ddfd7ab335255 Author: Mark Thomas <ma...@apache.org> AuthorDate: Tue Jul 14 21:29:31 2020 +0100 Ensure WebSocket connection write lock is released on exception --- .../org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java | 11 ++++++++++- webapps/docs/changelog.xml | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java b/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java index 08f3bf3..ba542a4 100644 --- a/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java +++ b/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java @@ -45,6 +45,7 @@ import jakarta.websocket.SendResult; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; +import org.apache.tomcat.util.ExceptionUtils; import org.apache.tomcat.util.buf.Utf8Encoder; import org.apache.tomcat.util.res.StringManager; @@ -306,7 +307,15 @@ public abstract class WsRemoteEndpointImplBase implements RemoteEndpoint { } for (MessagePart mp : messageParts) { - writeMessagePart(mp); + try { + writeMessagePart(mp); + } catch (Throwable t) { + ExceptionUtils.handleThrowable(t); + messagePartInProgress.release(); + wsSession.doClose(new CloseReason(CloseCodes.GOING_AWAY, t.getMessage()), + new CloseReason(CloseCodes.CLOSED_ABNORMALLY, t.getMessage())); + throw t; + } if (!bsh.getSendResult().isOK()) { messagePartInProgress.release(); Throwable t = bsh.getSendResult().getException(); diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 42783b5..3d78b27 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -80,6 +80,10 @@ <code>https</code>. Ensure that such requests are not rejected. PR provided by Ronny Perinke. (markt) </fix> + <fix> + Fix a potential issue where the write lock for a WebSocket connection + may not be released if an exception occurs during the write. (markt) + </fix> </changelog> </subsection> <subsection name="Web applications"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org