RFR: 8375352: java/net/httpclient/ConnectTimeoutWithProxy*.java tests fail on EC2 [v2]

Daniel Fuchs dfuchs at openjdk.org
Thu Feb 5 11:11:27 UTC 2026


On Thu, 5 Feb 2026 08:53:19 GMT, Volkan Yazici <vyazici at openjdk.org> wrote:

>> test/jdk/java/net/httpclient/ConnectTimeoutTest.java line 148:
>> 
>>> 146:                 socket.connect(SERVER_SOCKET.getLocalSocketAddress(), 5000);
>>> 147:                 sockets.add(socket);
>>> 148:             } catch (ConnectException | SocketTimeoutException exception) {
>> 
>> Are you sure about catching `ConnectException` here? My own experience is that on platforms != windows I always get `SocketTimeoutException`.
>
> Yes. See the following snippet:
> 
> 
> var s0 = new ServerSocket(0, 1, InetAddress.getLoopbackAddress()); // note backlog=1
> var s1 = new Socket(s0.getInetAddress(), s0.getLocalPort());
> // Following line
> // - works on Linux
> // - fails on Windows with `java.net.ConnectException: Connection refused: connect`
> // - fails on macOS with `java.net.ConnectException: Operation timed out`
> var s2 = new Socket(s0.getInetAddress(), s0.getLocalPort());
> 
> 
> OS versions:
> 
> - Oracle Linux 8 (amd64)
> - Windows Server 2022 10.0 (amd64)
> - Mac OS X 15.7 (x86_64)
> 
> I will privately share the JTreg logs with you.

OK - this is because the OS specific timeout kicks in. So you might get a `ConnectException` if the timeout you provide to connect() exceeds the OS/platform specific timeout. Otherwise you get the `SocketTimeoutException`. In my experiment (from which I excluded windows), I never got to trigger the `ConnectException`. I was using a timeout of `250 + Utils.adjustTimeout(250)`. It's OK to keep the ConnectException then. But I'm still wondering: does 5000 trigger the ConnectException?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/29431#discussion_r2768455928


More information about the net-dev mailing list