Skip to content

Commit 08215ae

Browse files
Shivangi Guptajaikiran
authored andcommitted
8373807: test/jdk/java/net/httpclient/websocket/DummyWebSocketServer.java getURI() uses "localhost"
Reviewed-by: jpai Backport-of: f3a4856
1 parent 5964a12 commit 08215ae

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

test/jdk/java/net/httpclient/websocket/DummyWebSocketServer.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,14 @@ URI getURI() {
351351
if (!started.get()) {
352352
throw new IllegalStateException("Not yet started");
353353
}
354-
return URI.create("ws://localhost:" + address.getPort());
354+
String ip = address.getAddress().isAnyLocalAddress()
355+
? InetAddress.getLoopbackAddress().getHostAddress()
356+
: address.getAddress().getHostAddress();
357+
if (ip.indexOf(':') >= 0) {
358+
ip = String.format("[%s]", ip);
359+
}
360+
361+
return URI.create("ws://" + ip + ":" + address.getPort());
355362
}
356363

357364
private boolean readRequest(SocketChannel channel, StringBuilder request)

0 commit comments

Comments
 (0)