test/jdk/java/net/httpclient/http2/server/Http2TestServer.java
branchhttp-client-branch
changeset 56265 ec34ae013fbe
parent 56233 1753108d07b9
child 56451 9585061fdb04
--- a/test/jdk/java/net/httpclient/http2/server/Http2TestServer.java	Thu Mar 08 17:41:52 2018 +0000
+++ b/test/jdk/java/net/httpclient/http2/server/Http2TestServer.java	Thu Mar 08 17:42:16 2018 +0000
@@ -78,6 +78,11 @@
         return (InetSocketAddress)server.getLocalSocketAddress();
     }
 
+    public String serverAuthority() {
+        return InetAddress.getLoopbackAddress().getHostName() + ":"
+                + getAddress().getPort();
+    }
+
     public Http2TestServer(boolean secure,
                            SSLContext context) throws Exception {
         this(null, secure, 0, null, context);
@@ -169,7 +174,7 @@
     final ServerSocket initPlaintext(int port) throws Exception {
         ServerSocket ss = new ServerSocket();
         ss.setReuseAddress(false);
-        ss.bind(new InetSocketAddress(0));
+        ss.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
         return ss;
     }
 
@@ -196,7 +201,7 @@
         }
         SSLServerSocket se = (SSLServerSocket) fac.createServerSocket();
         se.setReuseAddress(false);
-        se.bind(new InetSocketAddress(0));
+        se.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
         SSLParameters sslp = se.getSSLParameters();
         sslp.setApplicationProtocols(new String[]{"h2"});
         sslp.setEndpointIdentificationAlgorithm("HTTPS");