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 8d3ab06f94 Re-order to avoid resource leak if invalid timeout specified 8d3ab06f94 is described below commit 8d3ab06f94db6bfaaf4e85c1176515a924eff7f6 Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed Jul 5 14:18:56 2023 +0100 Re-order to avoid resource leak if invalid timeout specified Identified by Coverity Scan --- java/org/apache/tomcat/websocket/WsWebSocketContainer.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java index 75cd966e45..847c77f68c 100644 --- a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java +++ b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java @@ -260,13 +260,6 @@ public class WsWebSocketContainer implements WebSocketContainer, BackgroundProce } ByteBuffer request = createRequest(path, reqHeaders); - AsynchronousSocketChannel socketChannel; - try { - socketChannel = AsynchronousSocketChannel.open(getAsynchronousChannelGroup()); - } catch (IOException ioe) { - throw new DeploymentException(sm.getString("wsWebSocketContainer.asynchronousSocketChannelFail"), ioe); - } - // Get the connection timeout long timeout = Constants.IO_TIMEOUT_MS_DEFAULT; String timeoutValue = (String) userProperties.get(Constants.IO_TIMEOUT_MS_PROPERTY); @@ -274,6 +267,13 @@ public class WsWebSocketContainer implements WebSocketContainer, BackgroundProce timeout = Long.valueOf(timeoutValue).intValue(); } + AsynchronousSocketChannel socketChannel; + try { + socketChannel = AsynchronousSocketChannel.open(getAsynchronousChannelGroup()); + } catch (IOException ioe) { + throw new DeploymentException(sm.getString("wsWebSocketContainer.asynchronousSocketChannelFail"), ioe); + } + // Set-up // Same size as the WsFrame input buffer ByteBuffer response = ByteBuffer.allocate(getDefaultMaxBinaryMessageBufferSize()); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org