test/jdk/java/net/httpclient/HandshakeFailureTest.java
branchhttp-client-branch
changeset 56233 1753108d07b9
parent 56167 96fa4f49a9ff
child 56265 ec34ae013fbe
equal deleted inserted replaced
56227:278e1c6c3e99 56233:1753108d07b9
    26 import javax.net.ssl.SSLHandshakeException;
    26 import javax.net.ssl.SSLHandshakeException;
    27 import javax.net.ssl.SSLSocket;
    27 import javax.net.ssl.SSLSocket;
    28 import java.io.DataInputStream;
    28 import java.io.DataInputStream;
    29 import java.io.IOException;
    29 import java.io.IOException;
    30 import java.io.UncheckedIOException;
    30 import java.io.UncheckedIOException;
       
    31 import java.net.InetSocketAddress;
    31 import java.net.ServerSocket;
    32 import java.net.ServerSocket;
    32 import java.net.Socket;
    33 import java.net.Socket;
    33 import java.net.URI;
    34 import java.net.URI;
    34 import java.util.List;
    35 import java.util.List;
    35 import java.util.concurrent.CompletableFuture;
    36 import java.util.concurrent.CompletableFuture;
   171         protected final ServerSocket ss;
   172         protected final ServerSocket ss;
   172         protected volatile boolean closed;
   173         protected volatile boolean closed;
   173 
   174 
   174         AbstractServer(String name, ServerSocket ss) throws IOException {
   175         AbstractServer(String name, ServerSocket ss) throws IOException {
   175             super(name);
   176             super(name);
       
   177             ss.setReuseAddress(false);
       
   178             ss.bind(new InetSocketAddress(0));
   176             this.ss = ss;
   179             this.ss = ss;
   177             this.start();
   180             this.start();
   178         }
   181         }
   179 
   182 
   180         int getPort() { return ss.getLocalPort(); }
   183         int getPort() { return ss.getLocalPort(); }
   196      * the connection, after a small variable delay. */
   199      * the connection, after a small variable delay. */
   197     static class PlainServer extends AbstractServer {
   200     static class PlainServer extends AbstractServer {
   198         private volatile int count;
   201         private volatile int count;
   199 
   202 
   200         PlainServer() throws IOException {
   203         PlainServer() throws IOException {
   201             super("PlainServer", new ServerSocket(0));
   204             super("PlainServer", new ServerSocket());
   202         }
   205         }
   203 
   206 
   204         @Override
   207         @Override
   205         public void run() {
   208         public void run() {
   206             while (!closed) {
   209             while (!closed) {
   263                 throw new AssertionError(t);
   266                 throw new AssertionError(t);
   264             }
   267             }
   265         }
   268         }
   266 
   269 
   267         SSLServer() throws IOException {
   270         SSLServer() throws IOException {
   268             super("SSLServer", factory.createServerSocket(0));
   271             super("SSLServer", factory.createServerSocket());
   269         }
   272         }
   270 
   273 
   271         @Override
   274         @Override
   272         public void run() {
   275         public void run() {
   273             while (!closed) {
   276             while (!closed) {