This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
     new 0499b0d613 Re-order to avoid resource leak if invalid timeout specified
0499b0d613 is described below

commit 0499b0d613737c43c92c00c4e637ea28989108f0
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 5b8ac49ba1..2e4d015a5f 100644
--- a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
+++ b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
@@ -261,13 +261,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);
@@ -275,6 +268,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

Reply via email to