This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new 5707895 Ensure WebSocket connection write lock is released on exception 5707895 is described below commit 5707895bafa38c1443460356a268932a967b79e9 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 e40b98e..7d6d826 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -76,6 +76,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