Skip to content

Commit a195e8a

Browse files
rm-gh-8Paul Hohensee
authored andcommitted
8373807: test/jdk/java/net/httpclient/websocket/DummyWebSocketServer.java getURI() uses "localhost"
Backport-of: f3a48560b5e3a280f6f76031eb3d475ff9ee49f4
1 parent 97eaf9a commit a195e8a

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)