test/jdk/java/net/httpclient/http2/server/Http2TestServer.java
branchhttp-client-branch
changeset 56505 3b4b23c3758e
parent 56451 9585061fdb04
child 56507 2294c51eae30
--- a/test/jdk/java/net/httpclient/http2/server/Http2TestServer.java	Tue May 01 19:14:46 2018 +0100
+++ b/test/jdk/java/net/httpclient/http2/server/Http2TestServer.java	Tue May 01 22:37:29 2018 +0100
@@ -67,11 +67,11 @@
     }
 
     public Http2TestServer(String serverName, boolean secure, int port) throws Exception {
-        this(serverName, secure, port, getDefaultExecutor(), null);
+        this(serverName, secure, port, getDefaultExecutor(), 50, null);
     }
 
     public Http2TestServer(boolean secure, int port) throws Exception {
-        this(null, secure, port, getDefaultExecutor(), null);
+        this(null, secure, port, getDefaultExecutor(), 50, null);
     }
 
     public InetSocketAddress getAddress() {
@@ -85,19 +85,29 @@
 
     public Http2TestServer(boolean secure,
                            SSLContext context) throws Exception {
-        this(null, secure, 0, null, context);
+        this(null, secure, 0, null, 50, context);
     }
 
     public Http2TestServer(String serverName, boolean secure,
                            SSLContext context) throws Exception {
-        this(serverName, secure, 0, null, context);
+        this(serverName, secure, 0, null, 50, context);
     }
 
     public Http2TestServer(boolean secure,
                            int port,
                            ExecutorService exec,
                            SSLContext context) throws Exception {
-        this(null, secure, port, exec, context);
+        this(null, secure, port, exec, 50, context);
+    }
+
+    public Http2TestServer(String serverName,
+                           boolean secure,
+                           int port,
+                           ExecutorService exec,
+                           SSLContext context)
+        throws Exception
+    {
+        this(serverName, secure, port, exec, 50, context);
     }
 
     /**
@@ -109,20 +119,22 @@
      * @param secure https or http
      * @param port listen port
      * @param exec executor service (cached thread pool is used if null)
+     * @param backlog the server socket backlog
      * @param context the SSLContext used when secure is true
      */
     public Http2TestServer(String serverName,
                            boolean secure,
                            int port,
                            ExecutorService exec,
+                           int backlog,
                            SSLContext context)
         throws Exception
     {
         this.serverName = serverName;
         if (secure) {
-            server = initSecure(port);
+            server = initSecure(port, backlog);
         } else {
-            server = initPlaintext(port);
+            server = initPlaintext(port, backlog);
         }
         this.secure = secure;
         this.exec = exec == null ? getDefaultExecutor() : exec;
@@ -171,10 +183,10 @@
         return handler;
     }
 
-    final ServerSocket initPlaintext(int port) throws Exception {
+    final ServerSocket initPlaintext(int port, int backlog) throws Exception {
         ServerSocket ss = new ServerSocket();
         ss.setReuseAddress(false);
-        ss.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
+        ss.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), backlog);
         return ss;
     }
 
@@ -192,7 +204,7 @@
     }
 
 
-    final ServerSocket initSecure(int port) throws Exception {
+    final ServerSocket initSecure(int port, int backlog) throws Exception {
         ServerSocketFactory fac;
         if (sslContext != null) {
             fac = sslContext.getServerSocketFactory();
@@ -201,7 +213,7 @@
         }
         SSLServerSocket se = (SSLServerSocket) fac.createServerSocket();
         se.setReuseAddress(false);
-        se.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
+        se.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), backlog);
         SSLParameters sslp = se.getSSLParameters();
         sslp.setApplicationProtocols(new String[]{"h2"});
         sslp.setEndpointIdentificationAlgorithm("HTTPS");