diff -r 278e1c6c3e99 -r 1753108d07b9 test/jdk/java/net/httpclient/http2/server/Http2TestServer.java --- 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");