You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2023/07/05 13:19:28 UTC

[tomcat] branch 9.0.x updated: Re-order to avoid resource leak if invalid timeout specified

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 3302082915 Re-order to avoid resource leak if invalid timeout specified
3302082915 is described below

commit 3302082915feb2c27171616f63e674c78a02281c
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 4292702f11..6655a2cb71 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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org