RFR: 8373807: test/jdk/java/net/httpclient/websocket/DummyWebSocketServer.java getURI() uses "localhost"
Daniel Fuchs
dfuchs at openjdk.org
Wed Dec 17 10:58:09 UTC 2025
On Wed, 17 Dec 2025 10:53:03 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:
>> The WebSockteTest was observed failing in timeout once, waiting for the completable future returned by `WebSocketBuilder::build` to complete. The suspicion is that it may have been caused by the request being misdirected due to the use of "localhost" in the URI.
>>
>> This trivial fix ensures that the DumyWebSocketServer::getURI returns a URI with a literal IP address instead of relying on "localhost".
>
> test/jdk/java/net/httpclient/websocket/DummyWebSocketServer.java line 356:
>
>> 354: String ip = address.getAddress().isAnyLocalAddress()
>> 355: ? InetAddress.getLoopbackAddress().getHostAddress()
>> 356: : address.getAddress().getHostAddress();
>
> Hello Daniel, this looks OK to me. But given that we always use loopback address to bind the ServerSocketChannel in this test (line 333), can we just use loopback address here too?
We could - I added a check to `.isAnyLocalAddress()` to make it generic and not make any assumption on the address the server would bind to.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28864#discussion_r2626588152
More information about the net-dev
mailing list