RFR: 8375352: java/net/httpclient/ConnectTimeoutWithProxy*.java tests fail on EC2 [v2]
Daniel Fuchs
dfuchs at openjdk.org
Wed Feb 4 17:08:17 UTC 2026
On Tue, 27 Jan 2026 14:42:15 GMT, Volkan Yazici <vyazici at openjdk.org> wrote:
>> Fix tests using `AbstractConnectTimeout` by replacing the usage of an external host (i.e., `example.com`), which unexpectedly resolves to a real IP address on certain test hosts, with a custom `ServerSocket` bootstrapped by the test.
>>
>> The initial PR contains 3 commits:
>>
>> 1. b06f2606c88 Replace external domain with a custom `ServerSocket` (i.e., _"the fix"_)
>> 2. b9262c7ca01 Remove the need for multiple test files
>> 3. d95a335db93 Migrate tests to JUnit
>>
>> All commits (i.e., 1, 1+2, and 1+2+3) pass tests.
>
> Volkan Yazici has updated the pull request incrementally with one additional commit since the last revision:
>
> Apply review feedback
test/jdk/java/net/httpclient/ConnectTimeoutTest.java line 146:
> 144: (socketIndex + 1), maxSocketCount);
> 145: Socket socket = new Socket();
> 146: socket.connect(SERVER_SOCKET.getLocalSocketAddress(), 5000);
There's no way to escape magic numbers here, but maybe there's a way to adjust this timeout? Did you observe that 5000 was actually required?
Maybe something like `500 + Utils.adjustTimeout(500)` might work?
That would make it 1s for running locally, 2.5s when running in tier2...
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`.
test/jdk/java/net/httpclient/ConnectTimeoutTest.java line 329:
> 327: private static boolean isAcceptableCause(Throwable cause) {
> 328: if (cause instanceof NoRouteToHostException) return true;
> 329: if (cause instanceof UnresolvedAddressException) return true;
NoRouteToHostException and UnresolvedAddressException should not happen with the loopback.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29431#discussion_r2765017531
PR Review Comment: https://git.openjdk.org/jdk/pull/29431#discussion_r2765031710
PR Review Comment: https://git.openjdk.org/jdk/pull/29431#discussion_r2765044205
More information about the net-dev
mailing list