This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push: new 9ee2a2f63e Re-order to avoid resource leak if invalid timeout specified 9ee2a2f63e is described below commit 9ee2a2f63ed0b683c8ab79e8038f82d45f316bb9 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 bb5fd4b00d..0750be7eea 100644 --- a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java +++ b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java @@ -255,13 +255,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); @@ -269,6 +262,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