test/jdk/java/net/httpclient/http2/server/Http2TestServer.java
branchhttp-client-branch
changeset 56233 1753108d07b9
parent 56210 efa5db108669
child 56265 ec34ae013fbe
--- a/test/jdk/java/net/httpclient/http2/server/Http2TestServer.java	Fri Mar 02 15:14:03 2018 +0000
+++ b/test/jdk/java/net/httpclient/http2/server/Http2TestServer.java	Sat Mar 03 09:54:31 2018 +0000
@@ -167,7 +167,10 @@
     }
 
     final ServerSocket initPlaintext(int port) throws Exception {
-        return new ServerSocket(port);
+        ServerSocket ss = new ServerSocket();
+        ss.setReuseAddress(false);
+        ss.bind(new InetSocketAddress(0));
+        return ss;
     }
 
     public synchronized void stop() {
@@ -191,7 +194,9 @@
         } else {
             fac = SSLServerSocketFactory.getDefault();
         }
-        SSLServerSocket se = (SSLServerSocket) fac.createServerSocket(port);
+        SSLServerSocket se = (SSLServerSocket) fac.createServerSocket();
+        se.setReuseAddress(false);
+        se.bind(new InetSocketAddress(0));
         SSLParameters sslp = se.getSSLParameters();
         sslp.setApplicationProtocols(new String[]{"h2"});
         sslp.setEndpointIdentificationAlgorithm("HTTPS");