< prev index next >

src/java.base/share/classes/java/net/HttpConnectSocketImpl.java

Print this page

        

@@ -50,10 +50,11 @@
     private static final Field serverSocketField;
     private static final Method doTunneling;
 
     private final String server;
     private InetSocketAddress external_address;
+    private final Socket socket;
     private HashMap<Integer, Object> optionsMap = new HashMap<>();
 
     static  {
         try {
             Class<?> httpClazz = Class.forName(httpURLClazzStr, true, null);

@@ -73,19 +74,20 @@
         } catch (ReflectiveOperationException x) {
             throw new InternalError("Should not reach here", x);
         }
     }
 
-    HttpConnectSocketImpl(Proxy proxy, SocketImpl delegate) {
+    HttpConnectSocketImpl(Proxy proxy, SocketImpl delegate, Socket socket) {
         super(delegate);
         SocketAddress a = proxy.address();
         if ( !(a instanceof InetSocketAddress) )
             throw new IllegalArgumentException("Unsupported address type");
 
         InetSocketAddress ad = (InetSocketAddress) a;
         server = ad.getHostString();
         port = ad.getPort();
+        this.socket = socket;
     }
 
     @Override
     protected void connect(String host, int port) throws IOException {
         connect(new InetSocketAddress(host, port), 0);

@@ -95,21 +97,10 @@
     protected void connect(InetAddress address, int port) throws IOException {
         connect(new InetSocketAddress(address, port), 0);
     }
 
     @Override
-    void setSocket(Socket socket) {
-        delegate.socket = socket;
-        super.setSocket(socket);
-    }
-
-    @Override
-    void setServerSocket(ServerSocket socket) {
-        throw new InternalError("should not get here");
-    }
-
-    @Override
     protected void connect(SocketAddress endpoint, int timeout)
         throws IOException
     {
         if (endpoint == null || !(endpoint instanceof InetSocketAddress))
             throw new IllegalArgumentException("Unsupported address type");

@@ -135,11 +126,11 @@
         // close the original socket impl and release its descriptor
         close();
 
         // update the Sockets impl to the impl from the http Socket
         SocketImpl si = httpSocket.impl;
-        getSocket().setImpl(si);
+        socket.setImpl(si);   // TODO REMOVE: Is this ok, or delegating?
 
         // best effort is made to try and reset options previously set
         Set<Map.Entry<Integer,Object>> options = optionsMap.entrySet();
         try {
             for(Map.Entry<Integer,Object> entry : options) {
< prev index next >