--- old/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/SSLDelegate.java 2017-11-30 04:04:10.634071181 -0800 +++ new/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/SSLDelegate.java 2017-11-30 04:04:10.404051072 -0800 @@ -28,8 +28,6 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.SocketChannel; -import java.util.Arrays; -import java.util.List; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import javax.net.ssl.SSLEngineResult.HandshakeStatus; @@ -41,60 +39,56 @@ /** * Implements the mechanics of SSL by managing an SSLEngine object. - * One of these is associated with each SSLConnection. + *

+ * This class is only used to implement the {@link + * AbstractAsyncSSLConnection.SSLConnectionChannel} which is handed of + * to RawChannelImpl when creating a WebSocket. */ class SSLDelegate { final SSLEngine engine; final EngineWrapper wrapper; final Lock handshaking = new ReentrantLock(); - final SSLParameters sslParameters; final SocketChannel chan; - final HttpClientImpl client; - final String serverName; - SSLDelegate(SSLEngine eng, SocketChannel chan, HttpClientImpl client, String sn) + SSLDelegate(SSLEngine eng, SocketChannel chan) { this.engine = eng; this.chan = chan; - this.client = client; this.wrapper = new EngineWrapper(chan, engine); - this.sslParameters = engine.getSSLParameters(); - this.serverName = sn; } // alpn[] may be null - SSLDelegate(SocketChannel chan, HttpClientImpl client, String[] alpn, String sn) - throws IOException - { - serverName = sn; - SSLContext context = client.sslContext(); - engine = context.createSSLEngine(); - engine.setUseClientMode(true); - SSLParameters sslp = client.sslParameters() - .orElseGet(context::getSupportedSSLParameters); - sslParameters = Utils.copySSLParameters(sslp); - if (sn != null) { - SNIHostName sni = new SNIHostName(sn); - sslParameters.setServerNames(List.of(sni)); - } - if (alpn != null) { - sslParameters.setApplicationProtocols(alpn); - Log.logSSL("SSLDelegate: Setting application protocols: {0}" + Arrays.toString(alpn)); - } else { - Log.logSSL("SSLDelegate: No application protocols proposed"); - } - engine.setSSLParameters(sslParameters); - wrapper = new EngineWrapper(chan, engine); - this.chan = chan; - this.client = client; - } - - SSLParameters getSSLParameters() { - return sslParameters; - } +// SSLDelegate(SocketChannel chan, HttpClientImpl client, String[] alpn, String sn) +// throws IOException +// { +// serverName = sn; +// SSLContext context = client.sslContext(); +// engine = context.createSSLEngine(); +// engine.setUseClientMode(true); +// SSLParameters sslp = client.sslParameters(); +// sslParameters = Utils.copySSLParameters(sslp); +// if (sn != null) { +// SNIHostName sni = new SNIHostName(sn); +// sslParameters.setServerNames(List.of(sni)); +// } +// if (alpn != null) { +// sslParameters.setApplicationProtocols(alpn); +// Log.logSSL("SSLDelegate: Setting application protocols: {0}" + Arrays.toString(alpn)); +// } else { +// Log.logSSL("SSLDelegate: No application protocols proposed"); +// } +// engine.setSSLParameters(sslParameters); +// wrapper = new EngineWrapper(chan, engine); +// this.chan = chan; +// this.client = client; +// } + +// SSLParameters getSSLParameters() { +// return sslParameters; +// } - private static long countBytes(ByteBuffer[] buffers, int start, int number) { + static long countBytes(ByteBuffer[] buffers, int start, int number) { long c = 0; for (int i=0; i