This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push: new e7cdb18 Ensure WebSocket connection write lock is released on exception e7cdb18 is described below commit e7cdb1854feee2b34a73389d2f9ad41ec0c9e051 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 548f5a9..c87f99e 100644 --- a/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java +++ b/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java @@ -45,6 +45,7 @@ import javax.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 02544fa..dff49fb 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -82,6 +82,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