test/jdk/sun/net/www/protocol/https/HttpsURLConnection/ImpactOnSNI.java
changeset 58108 5302477c8285
parent 47216 71c04702a3d5
equal deleted inserted replaced
58106:79186d82463e 58108:5302477c8285
     1 /*
     1 /*
     2  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    93      * terminate all hung threads after its timeout has expired,
    93      * terminate all hung threads after its timeout has expired,
    94      * currently 3 minutes by default, but you might try to be
    94      * currently 3 minutes by default, but you might try to be
    95      * smart about it....
    95      * smart about it....
    96      */
    96      */
    97 
    97 
       
    98     private SSLServerSocket createServerSocket(SSLServerSocketFactory sslssf)
       
    99         throws Exception {
       
   100         SSLServerSocket sslServerSocket =
       
   101             (SSLServerSocket)sslssf.createServerSocket();
       
   102         InetAddress localHost = InetAddress.getLocalHost();
       
   103         InetSocketAddress address = new InetSocketAddress(localHost, serverPort);
       
   104         sslServerSocket.bind(address);
       
   105         return sslServerSocket;
       
   106     }
       
   107 
    98     /*
   108     /*
    99      * Define the server side of the test.
   109      * Define the server side of the test.
   100      *
   110      *
   101      * If the server prematurely exits, serverReady will be set to true
   111      * If the server prematurely exits, serverReady will be set to true
   102      * to avoid infinite hangs.
   112      * to avoid infinite hangs.
   103      */
   113      */
   104     private void doServerSide() throws Exception {
   114     private void doServerSide() throws Exception {
   105         SSLServerSocketFactory sslssf =
   115         SSLServerSocketFactory sslssf =
   106             (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
   116             (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
   107         try (SSLServerSocket sslServerSocket =
   117         try (SSLServerSocket sslServerSocket = createServerSocket(sslssf)) {
   108                 (SSLServerSocket)sslssf.createServerSocket(serverPort)) {
       
   109 
   118 
   110             serverPort = sslServerSocket.getLocalPort();
   119             serverPort = sslServerSocket.getLocalPort();
   111 
   120 
   112             /*
   121             /*
   113              * Signal Client, we're ready for his connect.
   122              * Signal Client, we're ready for his connect.