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

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

commit fe484820a0e7b41f8679a3772f79b9f49b4ee5c3
Author: opencode <[email protected]>
AuthorDate: Sat Oct 17 12:57:55 2026 +0200

    Fix 32-bit truncation of the WebSocket client I/O timeout
    
    The connectToServerRecursive() method read the millisecond value of the
    org.apache.tomcat.websocket.IO_TIMEOUT_MS user property with
    Long.valueOf(...).intValue(), silently truncating it to 32 bits. A
    configured timeout greater than 2^31-1 ms (~24.8 days) was
    misinterpreted: a value whose low 32 bits are negative (e.g. 30 days)
    became a negative timeout, causing the subsequent Future.get(timeout,
    MILLISECONDS) calls for the connection, handshake and request/response
    steps to fail immediately, while other large values were silently
    shortened to their low 32 bits.
    
    Use longValue(). The value is only ever passed directly to
    Future.get(long, TimeUnit.MILLISECONDS), so the restored full long range
    introduces no deadline arithmetic issues, and behaviour for values
    within the previous int range is unchanged.
---
 java/org/apache/tomcat/websocket/WsWebSocketContainer.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java 
b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
index 842c8aa1cc..a89f799277 100644
--- a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
+++ b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
@@ -283,7 +283,7 @@ public class WsWebSocketContainer implements 
WebSocketContainer, BackgroundProce
         long timeout = Constants.IO_TIMEOUT_MS_DEFAULT;
         String timeoutValue = (String) 
userProperties.get(Constants.IO_TIMEOUT_MS_PROPERTY);
         if (timeoutValue != null) {
-            timeout = Long.valueOf(timeoutValue).intValue();
+            timeout = Long.valueOf(timeoutValue).longValue();
         }
 
         AsynchronousSocketChannel socketChannel;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to