hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1454679 - in /httpcomponents/httpclient/trunk/httpclient/src: examples/org/apache/http/examples/client/ main/java/org/apache/http/conn/ main/java/org/apache/http/impl/client/ main/java/org/apache/http/impl/conn/ main/java/org/apache/http/i...
Date Sat, 09 Mar 2013 09:46:34 GMT
Author: olegk
Date: Sat Mar  9 09:46:33 2013
New Revision: 1454679

URL: http://svn.apache.org/r1454679
Log:
Revised HttpClientConnectionManager API

Added:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ManagedHttpClientConnection.java   (contents, props changed)
      - copied, changed from r1450810, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/SocketClientConnection.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java   (contents, props changed)
      - copied, changed from r1450810, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionFactory.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionImpl.java   (contents, props changed)
      - copied, changed from r1450810, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SocketClientConnectionImpl.java
Removed:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/SocketClientConnection.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionFactory.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SocketClientConnectionImpl.java
Modified:
    httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientConfiguration.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ManagedClientConnection.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/ProxyClient.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractPooledConnAdapter.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedClientConnectionImpl.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MinimalClientExec.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicHttpClientConnectionManager.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionOperator.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingHttpClientConnectionManager.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientConfiguration.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientConfiguration.java?rev=1454679&r1=1454678&r2=1454679&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientConfiguration.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientConfiguration.java Sat Mar  9 09:46:33 2013
@@ -56,7 +56,7 @@ import org.apache.http.config.RegistryBu
 import org.apache.http.config.SocketConfig;
 import org.apache.http.conn.DnsResolver;
 import org.apache.http.conn.HttpConnectionFactory;
-import org.apache.http.conn.SocketClientConnection;
+import org.apache.http.conn.ManagedHttpClientConnection;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.socket.ConnectionSocketFactory;
 import org.apache.http.conn.socket.PlainSocketFactory;
@@ -68,7 +68,7 @@ import org.apache.http.impl.client.Basic
 import org.apache.http.impl.client.BasicCredentialsProvider;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
-import org.apache.http.impl.conn.DefaultClientConnectionFactory;
+import org.apache.http.impl.conn.ManagedHttpClientConnectionFactory;
 import org.apache.http.impl.conn.DefaultHttpResponseParser;
 import org.apache.http.impl.conn.DefaultHttpResponseParserFactory;
 import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
@@ -130,7 +130,7 @@ public class ClientConfiguration {
         // configuration parameters HTTP connection factory can control the size of
         // input / output buffers as well as determine message parser / writer routines
         // to be employed by individual connections.
-        HttpConnectionFactory<SocketClientConnection> connFactory = new DefaultClientConnectionFactory(
+        HttpConnectionFactory<ManagedHttpClientConnection> connFactory = new ManagedHttpClientConnectionFactory(
                 8 * 1024, requestWriterFactory, responseParserFactory);
 
         // Client HTTP connection objects when fully initialized can be bound to

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java?rev=1454679&r1=1454678&r2=1454679&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java Sat Mar  9 09:46:33 2013
@@ -27,11 +27,9 @@
 package org.apache.http.conn;
 
 import java.io.IOException;
-import java.net.InetSocketAddress;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.http.HttpClientConnection;
-import org.apache.http.HttpHost;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.protocol.HttpContext;
 
@@ -80,12 +78,18 @@ public interface HttpClientConnectionMan
 
     void connect(
             HttpClientConnection conn,
-            HttpHost host, InetSocketAddress localAddress,
+            HttpRoute route,
             int connectTimeout,
             HttpContext context) throws IOException;
 
     void upgrade(
-            HttpClientConnection conn, HttpHost host,
+            HttpClientConnection conn,
+            HttpRoute route,
+            HttpContext context) throws IOException;
+
+    void routeComplete(
+            HttpClientConnection conn,
+            HttpRoute route,
             HttpContext context) throws IOException;
 
     /**

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ManagedClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ManagedClientConnection.java?rev=1454679&r1=1454678&r2=1454679&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ManagedClientConnection.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ManagedClientConnection.java Sat Mar  9 09:46:33 2013
@@ -48,7 +48,7 @@ import org.apache.http.protocol.HttpCont
  */
 @Deprecated
 public interface ManagedClientConnection extends
-    HttpClientConnection, HttpRoutedConnection, SocketClientConnection, ConnectionReleaseTrigger {
+    HttpClientConnection, HttpRoutedConnection, ManagedHttpClientConnection, ConnectionReleaseTrigger {
 
     /**
      * Indicates whether this connection is secure.

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ManagedHttpClientConnection.java (from r1450810, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/SocketClientConnection.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ManagedHttpClientConnection.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ManagedHttpClientConnection.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/SocketClientConnection.java&r1=1450810&r2=1454679&rev=1454679&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/SocketClientConnection.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ManagedHttpClientConnection.java Sat Mar  9 09:46:33 2013
@@ -40,7 +40,9 @@ import org.apache.http.HttpInetConnectio
  *
  * @since 4.3
  */
-public interface SocketClientConnection extends HttpClientConnection, HttpInetConnection {
+public interface ManagedHttpClientConnection extends HttpClientConnection, HttpInetConnection {
+
+    String getId();
 
     void bind(Socket socket) throws IOException;
 

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ManagedHttpClientConnection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ManagedHttpClientConnection.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ManagedHttpClientConnection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java?rev=1454679&r1=1454678&r2=1454679&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java Sat Mar  9 09:46:33 2013
@@ -37,7 +37,7 @@ import org.apache.http.auth.AuthState;
 import org.apache.http.auth.Credentials;
 import org.apache.http.client.UserTokenHandler;
 import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.conn.SocketClientConnection;
+import org.apache.http.conn.ManagedHttpClientConnection;
 import org.apache.http.protocol.HttpContext;
 
 /**
@@ -76,8 +76,8 @@ public class DefaultUserTokenHandler imp
 
         if (userPrincipal == null) {
             final HttpConnection conn = clientContext.getConnection();
-            if (conn.isOpen() && conn instanceof SocketClientConnection) {
-                final SSLSession sslsession = ((SocketClientConnection) conn).getSSLSession();
+            if (conn.isOpen() && conn instanceof ManagedHttpClientConnection) {
+                final SSLSession sslsession = ((ManagedHttpClientConnection) conn).getSSLSession();
                 if (sslsession != null) {
                     userPrincipal = sslsession.getLocalPrincipal();
                 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/ProxyClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/ProxyClient.java?rev=1454679&r1=1454678&r2=1454679&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/ProxyClient.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/ProxyClient.java Sat Mar  9 09:46:33 2013
@@ -50,7 +50,7 @@ import org.apache.http.client.protocol.C
 import org.apache.http.client.protocol.RequestClientConnControl;
 import org.apache.http.config.ConnectionConfig;
 import org.apache.http.conn.HttpConnectionFactory;
-import org.apache.http.conn.SocketClientConnection;
+import org.apache.http.conn.ManagedHttpClientConnection;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.routing.RouteInfo.LayerType;
 import org.apache.http.conn.routing.RouteInfo.TunnelType;
@@ -61,7 +61,7 @@ import org.apache.http.impl.auth.DigestS
 import org.apache.http.impl.auth.KerberosSchemeFactory;
 import org.apache.http.impl.auth.NTLMSchemeFactory;
 import org.apache.http.impl.auth.SPNegoSchemeFactory;
-import org.apache.http.impl.conn.DefaultClientConnectionFactory;
+import org.apache.http.impl.conn.ManagedHttpClientConnectionFactory;
 import org.apache.http.message.BasicHttpRequest;
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParamConfig;
@@ -79,7 +79,7 @@ import org.apache.http.util.EntityUtils;
 @SuppressWarnings("deprecation")
 public class ProxyClient {
 
-    private final HttpConnectionFactory<SocketClientConnection> connFactory;
+    private final HttpConnectionFactory<ManagedHttpClientConnection> connFactory;
     private final ConnectionConfig connectionConfig;
     private final RequestConfig requestConfig;
     private final HttpProcessor httpProcessor;
@@ -94,11 +94,11 @@ public class ProxyClient {
      * @since 4.3
      */
     public ProxyClient(
-            final HttpConnectionFactory<SocketClientConnection> connFactory,
+            final HttpConnectionFactory<ManagedHttpClientConnection> connFactory,
             final ConnectionConfig connectionConfig,
             final RequestConfig requestConfig) {
         super();
-        this.connFactory = connFactory != null ? connFactory : DefaultClientConnectionFactory.INSTANCE;
+        this.connFactory = connFactory != null ? connFactory : ManagedHttpClientConnectionFactory.INSTANCE;
         this.connectionConfig = connectionConfig != null ? connectionConfig : ConnectionConfig.DEFAULT;
         this.requestConfig = requestConfig != null ? requestConfig : RequestConfig.DEFAULT;
         this.httpProcessor = new ImmutableHttpProcessor(new HttpRequestInterceptor[] {
@@ -172,7 +172,7 @@ public class ProxyClient {
                 this.requestConfig.getLocalAddress(),
                 proxy, false, TunnelType.TUNNELLED, LayerType.PLAIN);
 
-        final SocketClientConnection conn = this.connFactory.create(this.connectionConfig);
+        final ManagedHttpClientConnection conn = this.connFactory.create(this.connectionConfig);
         final HttpContext context = new BasicHttpContext();
         HttpResponse response = null;
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractPooledConnAdapter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractPooledConnAdapter.java?rev=1454679&r1=1454678&r2=1454679&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractPooledConnAdapter.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/AbstractPooledConnAdapter.java Sat Mar  9 09:46:33 2013
@@ -67,6 +67,10 @@ public abstract class AbstractPooledConn
         this.poolEntry = entry;
     }
 
+    public String getId() {
+        return null;
+    }
+
     /**
      * Obtains the pool entry.
      *

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java?rev=1454679&r1=1454678&r2=1454679&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java Sat Mar  9 09:46:33 2013
@@ -49,7 +49,7 @@ import org.apache.http.conn.DnsResolver;
 import org.apache.http.conn.HttpClientConnectionManager;
 import org.apache.http.conn.HttpConnectionFactory;
 import org.apache.http.conn.SchemePortResolver;
-import org.apache.http.conn.SocketClientConnection;
+import org.apache.http.conn.ManagedHttpClientConnection;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.socket.ConnectionSocketFactory;
 import org.apache.http.conn.socket.PlainSocketFactory;
@@ -81,10 +81,10 @@ public class BasicHttpClientConnectionMa
     private final Log log = LogFactory.getLog(getClass());
 
     private final HttpClientConnectionOperator connectionOperator;
-    private final HttpConnectionFactory<SocketClientConnection> connFactory;
+    private final HttpConnectionFactory<ManagedHttpClientConnection> connFactory;
 
     @GuardedBy("this")
-    private SocketClientConnection conn;
+    private ManagedHttpClientConnection conn;
 
     @GuardedBy("this")
     private HttpRoute route;
@@ -119,13 +119,13 @@ public class BasicHttpClientConnectionMa
 
     public BasicHttpClientConnectionManager(
             final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
-            final HttpConnectionFactory<SocketClientConnection> connFactory,
+            final HttpConnectionFactory<ManagedHttpClientConnection> connFactory,
             final SchemePortResolver schemePortResolver,
             final DnsResolver dnsResolver) {
         super();
         this.connectionOperator = new HttpClientConnectionOperator(
                 socketFactoryRegistry, schemePortResolver, dnsResolver);
-        this.connFactory = connFactory != null ? connFactory : DefaultClientConnectionFactory.INSTANCE;
+        this.connFactory = connFactory != null ? connFactory : ManagedHttpClientConnectionFactory.INSTANCE;
         this.expiry = Long.MAX_VALUE;
         this.socketConfig = SocketConfig.DEFAULT;
         this.connConfig = ConnectionConfig.DEFAULT;
@@ -133,7 +133,7 @@ public class BasicHttpClientConnectionMa
 
     public BasicHttpClientConnectionManager(
             final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
-            final HttpConnectionFactory<SocketClientConnection> connFactory) {
+            final HttpConnectionFactory<ManagedHttpClientConnection> connFactory) {
         this(socketFactoryRegistry, connFactory, null, null);
     }
 
@@ -302,25 +302,37 @@ public class BasicHttpClientConnectionMa
 
     public void connect(
             final HttpClientConnection conn,
-            final HttpHost host,
-            final InetSocketAddress localAddress,
+            final HttpRoute route,
             final int connectTimeout,
             final HttpContext context) throws IOException {
         Args.notNull(conn, "Connection");
-        Args.notNull(host, "HTTP host");
+        Args.notNull(route, "HTTP route");
         Asserts.check(conn == this.conn, "Connection not obtained from this manager");
+        HttpHost host;
+        if (route.getProxyHost() != null) {
+            host = route.getProxyHost();
+        } else {
+            host = route.getTargetHost();
+        }
+        final InetSocketAddress localAddress = route.getLocalSocketAddress();
         this.connectionOperator.connect(this.conn, host, localAddress,
                 connectTimeout, this.socketConfig, context);
     }
 
     public void upgrade(
             final HttpClientConnection conn,
-            final HttpHost host,
+            final HttpRoute route,
             final HttpContext context) throws IOException {
         Args.notNull(conn, "Connection");
-        Args.notNull(host, "HTTP host");
+        Args.notNull(route, "HTTP route");
         Asserts.check(conn == this.conn, "Connection not obtained from this manager");
-        this.connectionOperator.upgrade(this.conn, host, context);
+        this.connectionOperator.upgrade(this.conn, route.getTargetHost(), context);
+    }
+
+    public void routeComplete(
+            final HttpClientConnection conn,
+            final HttpRoute route,
+            final HttpContext context) throws IOException {
     }
 
     public synchronized void closeExpiredConnections() {

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java?rev=1454679&r1=1454678&r2=1454679&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java Sat Mar  9 09:46:33 2013
@@ -32,7 +32,7 @@ import java.util.concurrent.atomic.Atomi
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.http.annotation.ThreadSafe;
-import org.apache.http.conn.SocketClientConnection;
+import org.apache.http.conn.ManagedHttpClientConnection;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.pool.AbstractConnPool;
 import org.apache.http.pool.ConnFactory;
@@ -41,7 +41,7 @@ import org.apache.http.pool.ConnFactory;
  * @since 4.3
  */
 @ThreadSafe
-class CPool extends AbstractConnPool<HttpRoute, SocketClientConnection, CPoolEntry> {
+class CPool extends AbstractConnPool<HttpRoute, ManagedHttpClientConnection, CPoolEntry> {
 
     private static AtomicLong COUNTER = new AtomicLong();
 
@@ -50,7 +50,7 @@ class CPool extends AbstractConnPool<Htt
     private final TimeUnit tunit;
 
     public CPool(
-            final ConnFactory<HttpRoute, SocketClientConnection> connFactory,
+            final ConnFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
             final int defaultMaxPerRoute, final int maxTotal,
             final long timeToLive, final TimeUnit tunit) {
         super(connFactory, defaultMaxPerRoute, maxTotal);
@@ -59,7 +59,7 @@ class CPool extends AbstractConnPool<Htt
     }
 
     @Override
-    protected CPoolEntry createEntry(final HttpRoute route, final SocketClientConnection conn) {
+    protected CPoolEntry createEntry(final HttpRoute route, final ManagedHttpClientConnection conn) {
         final String id = Long.toString(COUNTER.getAndIncrement());
         return new CPoolEntry(this.log, id, route, conn, this.timeToLive, this.tunit);
     }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java?rev=1454679&r1=1454678&r2=1454679&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java Sat Mar  9 09:46:33 2013
@@ -33,7 +33,7 @@ import java.util.concurrent.TimeUnit;
 import org.apache.commons.logging.Log;
 import org.apache.http.HttpClientConnection;
 import org.apache.http.annotation.ThreadSafe;
-import org.apache.http.conn.SocketClientConnection;
+import org.apache.http.conn.ManagedHttpClientConnection;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.pool.PoolEntry;
 
@@ -41,20 +41,39 @@ import org.apache.http.pool.PoolEntry;
  * @since 4.3
  */
 @ThreadSafe
-class CPoolEntry extends PoolEntry<HttpRoute, SocketClientConnection> {
+class CPoolEntry extends PoolEntry<HttpRoute, ManagedHttpClientConnection> {
 
     private final Log log;
+    private volatile boolean routeComplete;
 
     public CPoolEntry(
             final Log log,
             final String id,
             final HttpRoute route,
-            final SocketClientConnection conn,
+            final ManagedHttpClientConnection conn,
             final long timeToLive, final TimeUnit tunit) {
         super(id, route, conn, timeToLive, tunit);
         this.log = log;
     }
 
+    public void markRouteComplete() {
+        this.routeComplete = true;
+    }
+
+    public boolean isRouteComplete() {
+        return this.routeComplete;
+    }
+
+    public void closeConnection() throws IOException {
+        final HttpClientConnection conn = getConnection();
+        conn.close();
+    }
+
+    public void shutdownConnection() throws IOException {
+        final HttpClientConnection conn = getConnection();
+        conn.shutdown();
+    }
+
     @Override
     public boolean isExpired(final long now) {
         final boolean expired = super.isExpired(now);
@@ -72,9 +91,8 @@ class CPoolEntry extends PoolEntry<HttpR
 
     @Override
     public void close() {
-        final HttpClientConnection conn = getConnection();
         try {
-            conn.close();
+            closeConnection();
         } catch (final IOException ex) {
             this.log.debug("I/O error closing connection", ex);
         }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java?rev=1454679&r1=1454678&r2=1454679&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java Sat Mar  9 09:46:33 2013
@@ -35,7 +35,7 @@ import java.lang.reflect.Proxy;
 import org.apache.http.HttpClientConnection;
 import org.apache.http.HttpConnection;
 import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.conn.SocketClientConnection;
+import org.apache.http.conn.ManagedHttpClientConnection;
 import org.apache.http.protocol.HttpContext;
 
 /**
@@ -88,23 +88,21 @@ class CPoolProxy implements InvocationHa
     public void close() throws IOException {
         final CPoolEntry local = this.poolEntry;
         if (local != null) {
-            final HttpClientConnection conn = local.getConnection();
-            conn.close();
+            local.closeConnection();
         }
     }
 
     public void shutdown() throws IOException {
         final CPoolEntry local = this.poolEntry;
         if (local != null) {
-            final HttpClientConnection conn = local.getConnection();
-            conn.shutdown();
+            local.shutdownConnection();
         }
     }
 
     public boolean isOpen() {
-        final HttpClientConnection conn = getConnection();
-        if (conn != null) {
-            return conn.isOpen();
+        final CPoolEntry local = this.poolEntry;
+        if (local != null) {
+            return !local.isClosed();
         } else {
             return false;
         }
@@ -153,7 +151,7 @@ class CPoolProxy implements InvocationHa
             final CPoolEntry poolEntry) {
         return (HttpClientConnection) Proxy.newProxyInstance(
                 CPoolProxy.class.getClassLoader(),
-                new Class<?>[] { SocketClientConnection.class, HttpContext.class },
+                new Class<?>[] { ManagedHttpClientConnection.class, HttpContext.class },
                 new CPoolProxy(poolEntry));
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java?rev=1454679&r1=1454678&r2=1454679&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java Sat Mar  9 09:46:33 2013
@@ -46,7 +46,7 @@ import org.apache.http.HttpResponse;
 import org.apache.http.HttpResponseFactory;
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.conn.OperatedClientConnection;
-import org.apache.http.conn.SocketClientConnection;
+import org.apache.http.conn.ManagedHttpClientConnection;
 import org.apache.http.impl.SocketHttpClientConnection;
 import org.apache.http.io.HttpMessageParser;
 import org.apache.http.io.SessionInputBuffer;
@@ -62,12 +62,12 @@ import org.apache.http.util.Args;
  *
  * @since 4.0
  *
- * @deprecated (4.3) deprecated in favor of {@link SocketClientConnectionImpl}.
+ * @deprecated (4.3) use {@link ManagedHttpClientConnectionFactory}.
  */
 @NotThreadSafe // connSecure, targetHost
 @Deprecated
 public class DefaultClientConnection extends SocketHttpClientConnection
-    implements OperatedClientConnection, SocketClientConnection, HttpContext {
+    implements OperatedClientConnection, ManagedHttpClientConnection, HttpContext {
 
     private final Log log = LogFactory.getLog(getClass());
     private final Log headerLog = LogFactory.getLog("org.apache.http.headers");
@@ -93,6 +93,10 @@ public class DefaultClientConnection ext
         this.attributes = new HashMap<String, Object>();
     }
 
+    public String getId() {
+        return null;
+    }
+
     public final HttpHost getTargetHost() {
         return this.targetHost;
     }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java?rev=1454679&r1=1454678&r2=1454679&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java Sat Mar  9 09:46:33 2013
@@ -45,7 +45,7 @@ import org.apache.http.conn.DnsResolver;
 import org.apache.http.conn.HttpClientConnectionManager;
 import org.apache.http.conn.HttpHostConnectException;
 import org.apache.http.conn.SchemePortResolver;
-import org.apache.http.conn.SocketClientConnection;
+import org.apache.http.conn.ManagedHttpClientConnection;
 import org.apache.http.conn.socket.ConnectionSocketFactory;
 import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
 import org.apache.http.conn.socket.PlainSocketFactory;
@@ -86,7 +86,7 @@ class HttpClientConnectionOperator {
     }
 
     public void connect(
-            final SocketClientConnection conn,
+            final ManagedHttpClientConnection conn,
             final HttpHost host,
             final InetSocketAddress localAddress,
             final int connectTimeout,
@@ -140,7 +140,7 @@ class HttpClientConnectionOperator {
     }
 
     public void upgrade(
-            final SocketClientConnection conn,
+            final ManagedHttpClientConnection conn,
             final HttpHost host,
             final HttpContext context) throws IOException {
         final HttpClientContext clientContext = HttpClientContext.adapt(context);

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedClientConnectionImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedClientConnectionImpl.java?rev=1454679&r1=1454678&r2=1454679&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedClientConnectionImpl.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedClientConnectionImpl.java Sat Mar  9 09:46:33 2013
@@ -56,7 +56,7 @@ import org.apache.http.util.Asserts;
 /**
  * @since 4.2
  *
- * @deprecated (4.3) no longer used.
+ * @deprecated (4.3) use {@link ManagedHttpClientConnectionFactory}.
  */
 @Deprecated
 @NotThreadSafe
@@ -83,6 +83,10 @@ class ManagedClientConnectionImpl implem
         this.duration = Long.MAX_VALUE;
     }
 
+    public String getId() {
+        return null;
+    }
+
     HttpPoolEntry getPoolEntry() {
         return this.poolEntry;
     }

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java (from r1450810, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionFactory.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionFactory.java&r1=1450810&r2=1454679&rev=1454679&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java Sat Mar  9 09:46:33 2013
@@ -31,13 +31,16 @@ import java.nio.charset.Charset;
 import java.nio.charset.CharsetDecoder;
 import java.nio.charset.CharsetEncoder;
 import java.nio.charset.CodingErrorAction;
+import java.util.concurrent.atomic.AtomicLong;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.annotation.Immutable;
 import org.apache.http.config.ConnectionConfig;
 import org.apache.http.conn.HttpConnectionFactory;
-import org.apache.http.conn.SocketClientConnection;
+import org.apache.http.conn.ManagedHttpClientConnection;
 import org.apache.http.impl.io.DefaultHttpRequestWriterFactory;
 import org.apache.http.io.HttpMessageParserFactory;
 import org.apache.http.io.HttpMessageWriterFactory;
@@ -47,17 +50,23 @@ import org.apache.http.util.Args;
  * @since 4.3
  */
 @Immutable
-public class DefaultClientConnectionFactory implements HttpConnectionFactory<SocketClientConnection> {
+public class ManagedHttpClientConnectionFactory implements HttpConnectionFactory<ManagedHttpClientConnection> {
+
+    private static final AtomicLong COUNTER = new AtomicLong();
 
     private static final int DEFAULT_BUFSIZE = 8 * 1024;
 
-    public static final DefaultClientConnectionFactory INSTANCE = new DefaultClientConnectionFactory();
+    public static final ManagedHttpClientConnectionFactory INSTANCE = new ManagedHttpClientConnectionFactory();
+
+    private final Log log = LogFactory.getLog(ManagedHttpClientConnectionImpl.class);
+    private final Log headerlog = LogFactory.getLog("org.apache.http.headers");
+    private final Log wirelog = LogFactory.getLog("org.apache.http.wire");
 
     private final int bufferSize;
     private final HttpMessageWriterFactory<HttpRequest> requestWriterFactory;
     private final HttpMessageParserFactory<HttpResponse> responseParserFactory;
 
-    public DefaultClientConnectionFactory(
+    public ManagedHttpClientConnectionFactory(
             final int bufferSize,
             final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
             final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
@@ -69,26 +78,26 @@ public class DefaultClientConnectionFact
             DefaultHttpResponseParserFactory.INSTANCE;
     }
 
-    public DefaultClientConnectionFactory(
+    public ManagedHttpClientConnectionFactory(
             final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
             final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
         this(DEFAULT_BUFSIZE, requestWriterFactory, responseParserFactory);
     }
 
-    public DefaultClientConnectionFactory(
+    public ManagedHttpClientConnectionFactory(
             final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
         this(null, responseParserFactory);
     }
 
-    public DefaultClientConnectionFactory(final int bufferSize) {
+    public ManagedHttpClientConnectionFactory(final int bufferSize) {
         this(bufferSize, null, null);
     }
 
-    public DefaultClientConnectionFactory() {
+    public ManagedHttpClientConnectionFactory() {
         this(DEFAULT_BUFSIZE, null, null);
     }
 
-    public SocketClientConnection create(final ConnectionConfig config) {
+    public ManagedHttpClientConnection create(final ConnectionConfig config) {
         final ConnectionConfig cconfig = config != null ? config : ConnectionConfig.DEFAULT;
         CharsetDecoder chardecoder = null;
         CharsetEncoder charencoder = null;
@@ -105,10 +114,18 @@ public class DefaultClientConnectionFact
             charencoder.onMalformedInput(malformedInputAction);
             charencoder.onUnmappableCharacter(unmappableInputAction);
         }
-        return new SocketClientConnectionImpl(bufferSize,
-                chardecoder, charencoder,
+        final String id = "http-outgoing-" + Long.toString(COUNTER.getAndIncrement());
+        return new ManagedHttpClientConnectionImpl(
+                id,
+                log,
+                headerlog,
+                wirelog,
+                bufferSize,
+                chardecoder,
+                charencoder,
                 cconfig.getMessageConstraints(),
-                null, null,
+                null,
+                null,
                 requestWriterFactory,
                 responseParserFactory);
     }

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionImpl.java (from r1450810, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SocketClientConnectionImpl.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionImpl.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionImpl.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SocketClientConnectionImpl.java&r1=1450810&r2=1454679&rev=1454679&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SocketClientConnectionImpl.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionImpl.java Sat Mar  9 09:46:33 2013
@@ -36,28 +36,24 @@ import java.nio.charset.CharsetDecoder;
 import java.nio.charset.CharsetEncoder;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicLong;
 
 import javax.net.ssl.SSLSession;
 import javax.net.ssl.SSLSocket;
 
 import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.http.Header;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.config.MessageConstraints;
-import org.apache.http.conn.SocketClientConnection;
+import org.apache.http.conn.ManagedHttpClientConnection;
 import org.apache.http.entity.ContentLengthStrategy;
 import org.apache.http.impl.DefaultBHttpClientConnection;
 import org.apache.http.io.HttpMessageParserFactory;
 import org.apache.http.io.HttpMessageWriterFactory;
 import org.apache.http.protocol.HttpContext;
 
-class SocketClientConnectionImpl extends DefaultBHttpClientConnection
-                                 implements SocketClientConnection, HttpContext {
-
-    private static final AtomicLong COUNT = new AtomicLong();
+class ManagedHttpClientConnectionImpl extends DefaultBHttpClientConnection
+                                 implements ManagedHttpClientConnection, HttpContext {
 
     private final String id;
     private final Log log;
@@ -67,7 +63,11 @@ class SocketClientConnectionImpl extends
 
     private volatile boolean shutdown;
 
-    public SocketClientConnectionImpl(
+    public ManagedHttpClientConnectionImpl(
+            final String id,
+            final Log log,
+            final Log headerlog,
+            final Log wirelog,
             final int buffersize,
             final CharsetDecoder chardecoder,
             final CharsetEncoder charencoder,
@@ -79,15 +79,15 @@ class SocketClientConnectionImpl extends
         super(buffersize, chardecoder, charencoder,
                 constraints, incomingContentStrategy, outgoingContentStrategy,
                 requestWriterFactory, responseParserFactory);
-        this.id = "http-outgoing-" + COUNT.incrementAndGet();
-        this.log = LogFactory.getLog(getClass());
-        this.headerlog = LogFactory.getLog("org.apache.http.headers");
-        this.wire = new Wire(LogFactory.getLog("org.apache.http.wire"), this.id);
+        this.id = id;
+        this.log = log;
+        this.headerlog = headerlog;
+        this.wire = new Wire(wirelog, this.id);
         this.attributes = new ConcurrentHashMap<String, Object>();
     }
 
-    public SocketClientConnectionImpl(final int buffersize) {
-        this(buffersize, null, null, null, null, null, null, null);
+    public String getId() {
+        return this.id;
     }
 
     @Override

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java?rev=1454679&r1=1454678&r2=1454679&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java Sat Mar  9 09:46:33 2013
@@ -52,7 +52,7 @@ import org.apache.http.conn.DnsResolver;
 import org.apache.http.conn.HttpClientConnectionManager;
 import org.apache.http.conn.HttpConnectionFactory;
 import org.apache.http.conn.SchemePortResolver;
-import org.apache.http.conn.SocketClientConnection;
+import org.apache.http.conn.ManagedHttpClientConnection;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.socket.ConnectionSocketFactory;
 import org.apache.http.conn.socket.PlainSocketFactory;
@@ -120,25 +120,25 @@ public class PoolingHttpClientConnection
 
     public PoolingHttpClientConnectionManager(
             final Registry<ConnectionSocketFactory> socketFactoryRegistry,
-            final HttpConnectionFactory<SocketClientConnection> connFactory) {
+            final HttpConnectionFactory<ManagedHttpClientConnection> connFactory) {
         this(socketFactoryRegistry, connFactory, null);
     }
 
     public PoolingHttpClientConnectionManager(
-            final HttpConnectionFactory<SocketClientConnection> connFactory) {
+            final HttpConnectionFactory<ManagedHttpClientConnection> connFactory) {
         this(getDefaultRegistry(), connFactory, null);
     }
 
     public PoolingHttpClientConnectionManager(
             final Registry<ConnectionSocketFactory> socketFactoryRegistry,
-            final HttpConnectionFactory<SocketClientConnection> connFactory,
+            final HttpConnectionFactory<ManagedHttpClientConnection> connFactory,
             final DnsResolver dnsResolver) {
         this(socketFactoryRegistry, connFactory, null, dnsResolver, -1, TimeUnit.MILLISECONDS);
     }
 
     public PoolingHttpClientConnectionManager(
             final Registry<ConnectionSocketFactory> socketFactoryRegistry,
-            final HttpConnectionFactory<SocketClientConnection> connFactory,
+            final HttpConnectionFactory<ManagedHttpClientConnection> connFactory,
             final SchemePortResolver schemePortResolver,
             final DnsResolver dnsResolver,
             final long timeToLive, final TimeUnit tunit) {
@@ -261,7 +261,7 @@ public class PoolingHttpClientConnection
             if (entry == null) {
                 return;
             }
-            final SocketClientConnection conn = entry.getConnection();
+            final ManagedHttpClientConnection conn = entry.getConnection();
             try {
                 if (conn.isOpen()) {
                     entry.setState(state);
@@ -277,7 +277,7 @@ public class PoolingHttpClientConnection
                     }
                 }
             } finally {
-                this.pool.release(entry, conn.isOpen());
+                this.pool.release(entry, conn.isOpen() && entry.isRouteComplete());
                 if (this.log.isDebugEnabled()) {
                     this.log.debug("Connection released: " + format(entry) + formatStats(entry.getRoute()));
                 }
@@ -287,16 +287,23 @@ public class PoolingHttpClientConnection
 
     public void connect(
             final HttpClientConnection managedConn,
-            final HttpHost host,
-            final InetSocketAddress localAddress,
+            final HttpRoute route,
             final int connectTimeout,
             final HttpContext context) throws IOException {
-        Args.notNull(managedConn, "Connection");
-        SocketClientConnection conn;
+        Args.notNull(managedConn, "Managed Connection");
+        Args.notNull(route, "HTTP route");
+        ManagedHttpClientConnection conn;
         synchronized (managedConn) {
             final CPoolEntry entry = CPoolProxy.getPoolEntry(managedConn);
             conn = entry.getConnection();
         }
+        final HttpHost host;
+        if (route.getProxyHost() != null) {
+            host = route.getProxyHost();
+        } else {
+            host = route.getTargetHost();
+        }
+        final InetSocketAddress localAddress = route.getLocalSocketAddress();
         SocketConfig socketConfig = this.configData.getSocketConfig(host);
         if (socketConfig == null) {
             socketConfig = this.configData.getDefaultSocketConfig();
@@ -310,15 +317,28 @@ public class PoolingHttpClientConnection
 
     public void upgrade(
             final HttpClientConnection managedConn,
-            final HttpHost host,
+            final HttpRoute route,
             final HttpContext context) throws IOException {
-        Args.notNull(managedConn, "Connection");
-        SocketClientConnection conn;
+        Args.notNull(managedConn, "Managed Connection");
+        Args.notNull(route, "HTTP route");
+        ManagedHttpClientConnection conn;
         synchronized (managedConn) {
             final CPoolEntry entry = CPoolProxy.getPoolEntry(managedConn);
             conn = entry.getConnection();
         }
-        this.connectionOperator.upgrade(conn, host, context);
+        this.connectionOperator.upgrade(conn, route.getTargetHost(), context);
+    }
+
+    public void routeComplete(
+            final HttpClientConnection managedConn,
+            final HttpRoute route,
+            final HttpContext context) throws IOException {
+        Args.notNull(managedConn, "Managed Connection");
+        Args.notNull(route, "HTTP route");
+        synchronized (managedConn) {
+            final CPoolEntry entry = CPoolProxy.getPoolEntry(managedConn);
+            entry.markRouteComplete();
+        }
     }
 
     public void shutdown() {
@@ -454,21 +474,21 @@ public class PoolingHttpClientConnection
 
     }
 
-    static class InternalConnectionFactory implements ConnFactory<HttpRoute, SocketClientConnection> {
+    static class InternalConnectionFactory implements ConnFactory<HttpRoute, ManagedHttpClientConnection> {
 
         private final ConfigData configData;
-        private final HttpConnectionFactory<SocketClientConnection> connFactory;
+        private final HttpConnectionFactory<ManagedHttpClientConnection> connFactory;
 
         InternalConnectionFactory(
                 final ConfigData configData,
-                final HttpConnectionFactory<SocketClientConnection> connFactory) {
+                final HttpConnectionFactory<ManagedHttpClientConnection> connFactory) {
             super();
             this.configData = configData != null ? configData : new ConfigData();
             this.connFactory = connFactory != null ? connFactory :
-                DefaultClientConnectionFactory.INSTANCE;
+                ManagedHttpClientConnectionFactory.INSTANCE;
         }
 
-        public SocketClientConnection create(final HttpRoute route) throws IOException {
+        public ManagedHttpClientConnection create(final HttpRoute route) throws IOException {
             ConnectionConfig config = null;
             if (route.getProxyHost() != null) {
                 config = this.configData.getConnectionConfig(route.getProxyHost());

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java?rev=1454679&r1=1454678&r2=1454679&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java Sat Mar  9 09:46:33 2013
@@ -360,7 +360,7 @@ public class MainClientExec implements C
             case HttpRouteDirector.CONNECT_TARGET:
                 this.connManager.connect(
                         managedConn,
-                        route.getTargetHost(), route.getLocalSocketAddress(),
+                        route,
                         timeout > 0 ? timeout : 0,
                         context);
                 tracker.connectTarget(route.isSecure());
@@ -368,7 +368,7 @@ public class MainClientExec implements C
             case HttpRouteDirector.CONNECT_PROXY:
                 this.connManager.connect(
                         managedConn,
-                        route.getProxyHost(), route.getLocalSocketAddress(),
+                        route,
                         timeout > 0 ? timeout : 0,
                         context);
                 final HttpHost proxy  = route.getProxyHost();
@@ -393,14 +393,15 @@ public class MainClientExec implements C
             }   break;
 
             case HttpRouteDirector.LAYER_PROTOCOL:
-                this.connManager.upgrade(managedConn, route.getTargetHost(), context);
+                this.connManager.upgrade(managedConn, route, context);
+                tracker.layerProtocol(route.isSecure());
                 break;
 
             case HttpRouteDirector.UNREACHABLE:
                 throw new HttpException("Unable to establish route: " +
                         "planned = " + route + "; current = " + fact);
             case HttpRouteDirector.COMPLETE:
-                // do nothing
+                this.connManager.routeComplete(managedConn, route, context);
                 break;
             default:
                 throw new IllegalStateException("Unknown step indicator "
@@ -441,7 +442,7 @@ public class MainClientExec implements C
             if (!managedConn.isOpen()) {
                 this.connManager.connect(
                         managedConn,
-                        route.getProxyHost(), route.getLocalSocketAddress(),
+                        route,
                         timeout > 0 ? timeout : 0,
                         context);
             }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MinimalClientExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MinimalClientExec.java?rev=1454679&r1=1454678&r2=1454679&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MinimalClientExec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MinimalClientExec.java Sat Mar  9 09:46:33 2013
@@ -154,9 +154,10 @@ public class MinimalClientExec implement
                 final int timeout = config.getConnectTimeout();
                 this.connManager.connect(
                     managedConn,
-                    route.getTargetHost(), route.getLocalSocketAddress(),
+                    route,
                     timeout > 0 ? timeout : 0,
                     context);
+                this.connManager.routeComplete(managedConn, route, context);
             } else {
                 final int timeout = config.getSocketTimeout();
                 if (timeout >= 0) {

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java?rev=1454679&r1=1454678&r2=1454679&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java Sat Mar  9 09:46:33 2013
@@ -296,8 +296,7 @@ public class TestAbortHandling extends I
         final HttpClientConnectionManager connmgr = Mockito.mock(HttpClientConnectionManager.class);
         Mockito.doThrow(new ConnectException()).when(connmgr).connect(
                 Mockito.any(HttpClientConnection.class),
-                Mockito.any(HttpHost.class),
-                Mockito.any(InetSocketAddress.class),
+                Mockito.any(HttpRoute.class),
                 Mockito.anyInt(),
                 Mockito.any(HttpContext.class));
 
@@ -464,6 +463,28 @@ public class TestAbortHandling extends I
 
         public void connect(
                 final HttpClientConnection conn,
+                final HttpRoute route,
+                final int connectTimeout,
+                final HttpContext context) throws IOException {
+            throw new UnsupportedOperationException("just a mockup");
+        }
+
+        public void upgrade(
+                final HttpClientConnection conn,
+                final HttpRoute route,
+                final HttpContext context) throws IOException {
+            throw new UnsupportedOperationException("just a mockup");
+        }
+
+        public void routeComplete(
+                final HttpClientConnection conn,
+                final HttpRoute route,
+                final HttpContext context) throws IOException {
+            throw new UnsupportedOperationException("just a mockup");
+        }
+
+        public void connect(
+                final HttpClientConnection conn,
                 final HttpHost host,
                 final InetSocketAddress localAddress,
                 final int connectTimeout,

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java?rev=1454679&r1=1454678&r2=1454679&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java Sat Mar  9 09:46:33 2013
@@ -113,7 +113,8 @@ public class TestConnectionManagement ex
         final HttpContext context = new BasicHttpContext();
 
         HttpClientConnection conn = getConnection(mgr, route);
-        mgr.connect(conn, route.getTargetHost(), route.getLocalSocketAddress(), 0, context);
+        mgr.connect(conn, route, 0, context);
+        mgr.routeComplete(conn, route, context);
 
         context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
         context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, target);
@@ -147,7 +148,8 @@ public class TestConnectionManagement ex
         conn = getConnection(mgr, route);
         Assert.assertFalse("connection should have been closed", conn.isOpen());
 
-        mgr.connect(conn, route.getTargetHost(), route.getLocalSocketAddress(), 0, context);
+        mgr.connect(conn, route, 0, context);
+        mgr.routeComplete(conn, route, context);
 
         // repeat the communication, no need to prepare the request again
         context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
@@ -201,7 +203,8 @@ public class TestConnectionManagement ex
         final HttpContext context = new BasicHttpContext();
 
         HttpClientConnection conn = getConnection(mgr, route);
-        mgr.connect(conn, route.getTargetHost(), route.getLocalSocketAddress(), 0, context);
+        mgr.connect(conn, route, 0, context);
+        mgr.routeComplete(conn, route, context);
 
         context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
         context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, target);
@@ -236,7 +239,8 @@ public class TestConnectionManagement ex
         Assert.assertFalse("connection should have been closed", conn.isOpen());
 
         // repeat the communication, no need to prepare the request again
-        mgr.connect(conn, route.getTargetHost(), route.getLocalSocketAddress(), 0, context);
+        mgr.connect(conn, route, 0, context);
+        mgr.routeComplete(conn, route, context);
 
         context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
         response = exec.execute(request, conn, context);
@@ -271,7 +275,8 @@ public class TestConnectionManagement ex
         Assert.assertTrue("connection should have been closed", !conn.isOpen());
 
         // repeat the communication, no need to prepare the request again
-        mgr.connect(conn, route.getTargetHost(), route.getLocalSocketAddress(), 0, context);
+        mgr.connect(conn, route, 0, context);
+        mgr.routeComplete(conn, route, context);
 
         context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
         response = exec.execute(request, conn, context);
@@ -298,7 +303,8 @@ public class TestConnectionManagement ex
         final HttpContext context = new BasicHttpContext();
 
         final HttpClientConnection conn = getConnection(mgr, route);
-        mgr.connect(conn, route.getTargetHost(), route.getLocalSocketAddress(), 0, context);
+        mgr.connect(conn, route, 0, context);
+        mgr.routeComplete(conn, route, context);
 
         Assert.assertEquals(1, mgr.getTotalStats().getLeased());
         Assert.assertEquals(1, mgr.getStats(route).getLeased());
@@ -338,7 +344,8 @@ public class TestConnectionManagement ex
         final HttpContext context = new BasicHttpContext();
 
         final HttpClientConnection conn = getConnection(mgr, route);
-        mgr.connect(conn, route.getTargetHost(), route.getLocalSocketAddress(), 0, context);
+        mgr.connect(conn, route, 0, context);
+        mgr.routeComplete(conn, route, context);
 
         Assert.assertEquals(1, mgr.getTotalStats().getLeased());
         Assert.assertEquals(1, mgr.getStats(route).getLeased());
@@ -386,7 +393,8 @@ public class TestConnectionManagement ex
             new BasicHttpRequest("GET", uri, HttpVersion.HTTP_1_1);
 
         HttpClientConnection conn = getConnection(mgr, route);
-        mgr.connect(conn, route.getTargetHost(), route.getLocalSocketAddress(), 0, context);
+        mgr.connect(conn, route, 0, context);
+        mgr.routeComplete(conn, route, context);
 
         context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
         context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, target);
@@ -458,7 +466,8 @@ public class TestConnectionManagement ex
         abortingThread.start();
 
         try {
-            mgr.connect(conn, route.getTargetHost(), route.getLocalSocketAddress(), 0, context);
+            mgr.connect(conn, route, 0, context);
+            mgr.routeComplete(conn, route, context);
             Assert.fail("expected SocketException");
         } catch(final SocketException expected) {}
 
@@ -512,7 +521,8 @@ public class TestConnectionManagement ex
         abortingThread.start();
 
         try {
-            mgr.connect(conn, route.getTargetHost(), route.getLocalSocketAddress(), 0, context);
+            mgr.connect(conn, route, 0, context);
+            mgr.routeComplete(conn, route, context);
             Assert.fail("IOException expected");
         } catch(final IOException expected) {
         }
@@ -567,7 +577,8 @@ public class TestConnectionManagement ex
         abortingThread.start();
 
         try {
-            mgr.connect(conn, route.getTargetHost(), route.getLocalSocketAddress(), 0, context);
+            mgr.connect(conn, route, 0, context);
+            mgr.routeComplete(conn, route, context);
             Assert.fail("IOException expected");
         } catch(final IOException expected) {
         }

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicHttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicHttpClientConnectionManager.java?rev=1454679&r1=1454678&r2=1454679&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicHttpClientConnectionManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestBasicHttpClientConnectionManager.java Sat Mar  9 09:46:33 2013
@@ -35,7 +35,7 @@ import org.apache.http.config.Connection
 import org.apache.http.config.Lookup;
 import org.apache.http.conn.ConnectionRequest;
 import org.apache.http.conn.HttpConnectionFactory;
-import org.apache.http.conn.SocketClientConnection;
+import org.apache.http.conn.ManagedHttpClientConnection;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.socket.ConnectionSocketFactory;
 import org.junit.Assert;
@@ -45,15 +45,15 @@ import org.mockito.Mockito;
 
 public class TestBasicHttpClientConnectionManager {
 
-    private SocketClientConnection conn;
-    private HttpConnectionFactory<SocketClientConnection> connFactory;
+    private ManagedHttpClientConnection conn;
+    private HttpConnectionFactory<ManagedHttpClientConnection> connFactory;
     private Lookup<ConnectionSocketFactory> socketFactoryRegistry;
     private BasicHttpClientConnectionManager mgr;
 
     @SuppressWarnings("unchecked")
     @Before
     public void setup() throws Exception {
-        conn = Mockito.mock(SocketClientConnection.class);
+        conn = Mockito.mock(ManagedHttpClientConnection.class);
         connFactory = Mockito.mock(HttpConnectionFactory.class);
         socketFactoryRegistry = Mockito.mock(Lookup.class);
         mgr = new BasicHttpClientConnectionManager(socketFactoryRegistry, connFactory);

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionOperator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionOperator.java?rev=1454679&r1=1454678&r2=1454679&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionOperator.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestHttpClientConnectionOperator.java Sat Mar  9 09:46:33 2013
@@ -37,7 +37,7 @@ import org.apache.http.config.SocketConf
 import org.apache.http.conn.ConnectTimeoutException;
 import org.apache.http.conn.DnsResolver;
 import org.apache.http.conn.SchemePortResolver;
-import org.apache.http.conn.SocketClientConnection;
+import org.apache.http.conn.ManagedHttpClientConnection;
 import org.apache.http.conn.socket.ConnectionSocketFactory;
 import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
 import org.apache.http.protocol.BasicHttpContext;
@@ -48,7 +48,7 @@ import org.mockito.Mockito;
 
 public class TestHttpClientConnectionOperator {
 
-    private SocketClientConnection conn;
+    private ManagedHttpClientConnection conn;
     private Socket socket;
     private ConnectionSocketFactory plainSocketFactory;
     private LayeredConnectionSocketFactory sslSocketFactory;
@@ -60,7 +60,7 @@ public class TestHttpClientConnectionOpe
     @SuppressWarnings("unchecked")
     @Before
     public void setup() throws Exception {
-        conn = Mockito.mock(SocketClientConnection.class);
+        conn = Mockito.mock(ManagedHttpClientConnection.class);
         socket = Mockito.mock(Socket.class);
         plainSocketFactory = Mockito.mock(ConnectionSocketFactory.class);
         sslSocketFactory = Mockito.mock(LayeredConnectionSocketFactory.class);

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingHttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingHttpClientConnectionManager.java?rev=1454679&r1=1454678&r2=1454679&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingHttpClientConnectionManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestPoolingHttpClientConnectionManager.java Sat Mar  9 09:46:33 2013
@@ -40,7 +40,7 @@ import org.apache.http.conn.ConnectionPo
 import org.apache.http.conn.ConnectionRequest;
 import org.apache.http.conn.DnsResolver;
 import org.apache.http.conn.SchemePortResolver;
-import org.apache.http.conn.SocketClientConnection;
+import org.apache.http.conn.ManagedHttpClientConnection;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.socket.ConnectionSocketFactory;
 import org.apache.http.protocol.HttpContext;
@@ -54,7 +54,7 @@ import org.mockito.Mockito;
  */
 public class TestPoolingHttpClientConnectionManager {
 
-    private SocketClientConnection conn;
+    private ManagedHttpClientConnection conn;
     private Socket socket;
     private ConnectionSocketFactory plainSocketFactory;
     private Lookup<ConnectionSocketFactory> socketFactoryRegistry;
@@ -67,7 +67,7 @@ public class TestPoolingHttpClientConnec
     @SuppressWarnings("unchecked")
     @Before
     public void setup() throws Exception {
-        conn = Mockito.mock(SocketClientConnection.class);
+        conn = Mockito.mock(ManagedHttpClientConnection.class);
         socket = Mockito.mock(Socket.class);
         plainSocketFactory = Mockito.mock(ConnectionSocketFactory.class);
         socketFactoryRegistry = Mockito.mock(Lookup.class);
@@ -86,12 +86,42 @@ public class TestPoolingHttpClientConnec
 
         final CPoolEntry entry = new CPoolEntry(LogFactory.getLog(getClass()), "id", route, conn,
                 -1, TimeUnit.MILLISECONDS);
+        entry.markRouteComplete();
 
         Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
         Mockito.when(socketFactoryRegistry.lookup("http")).thenReturn(plainSocketFactory);
         Mockito.when(schemePortResolver.resolve(target)).thenReturn(80);
         Mockito.when(plainSocketFactory.createSocket(Mockito.<HttpContext>any())).thenReturn(socket);
 
+        Mockito.when(conn.isOpen()).thenReturn(true);
+        Mockito.when(future.isCancelled()).thenReturn(false);
+        Mockito.when(future.get(1, TimeUnit.SECONDS)).thenReturn(entry);
+        Mockito.when(pool.lease(route, null, null)).thenReturn(future);
+
+        final ConnectionRequest connRequest1 = mgr.requestConnection(route, null);
+        final HttpClientConnection conn1 = connRequest1.get(1, TimeUnit.SECONDS);
+        Assert.assertNotNull(conn1);
+        Assert.assertNotSame(conn, conn1);
+
+        mgr.releaseConnection(conn1, null, 0, TimeUnit.MILLISECONDS);
+
+        Mockito.verify(pool).release(entry, true);
+    }
+
+    @Test
+    public void testReleaseRouteIncomplete() throws Exception {
+        final HttpHost target = new HttpHost("localhost");
+        final HttpRoute route = new HttpRoute(target);
+
+        final CPoolEntry entry = new CPoolEntry(LogFactory.getLog(getClass()), "id", route, conn,
+                -1, TimeUnit.MILLISECONDS);
+
+        Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
+        Mockito.when(socketFactoryRegistry.lookup("http")).thenReturn(plainSocketFactory);
+        Mockito.when(schemePortResolver.resolve(target)).thenReturn(80);
+        Mockito.when(plainSocketFactory.createSocket(Mockito.<HttpContext>any())).thenReturn(socket);
+
+        Mockito.when(conn.isOpen()).thenReturn(true);
         Mockito.when(future.isCancelled()).thenReturn(false);
         Mockito.when(future.get(1, TimeUnit.SECONDS)).thenReturn(entry);
         Mockito.when(pool.lease(route, null, null)).thenReturn(future);
@@ -99,7 +129,6 @@ public class TestPoolingHttpClientConnec
         final ConnectionRequest connRequest1 = mgr.requestConnection(route, null);
         final HttpClientConnection conn1 = connRequest1.get(1, TimeUnit.SECONDS);
         Assert.assertNotNull(conn1);
-        Assert.assertFalse(conn1.isOpen());
         Assert.assertNotSame(conn, conn1);
 
         mgr.releaseConnection(conn1, null, 0, TimeUnit.MILLISECONDS);
@@ -114,6 +143,7 @@ public class TestPoolingHttpClientConnec
 
         final CPoolEntry entry = new CPoolEntry(LogFactory.getLog(getClass()), "id", route, conn,
                 -1, TimeUnit.MILLISECONDS);
+        entry.markRouteComplete();
 
         Mockito.when(future.isCancelled()).thenReturn(Boolean.TRUE);
         Mockito.when(future.get(1, TimeUnit.SECONDS)).thenReturn(entry);
@@ -143,6 +173,7 @@ public class TestPoolingHttpClientConnec
 
         final CPoolEntry entry = Mockito.spy(new CPoolEntry(LogFactory.getLog(getClass()), "id", route, conn,
                 -1, TimeUnit.MILLISECONDS));
+        entry.markRouteComplete();
 
         Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
         Mockito.when(future.get(1, TimeUnit.SECONDS)).thenReturn(entry);
@@ -168,6 +199,7 @@ public class TestPoolingHttpClientConnec
 
         final CPoolEntry entry = Mockito.spy(new CPoolEntry(LogFactory.getLog(getClass()), "id", route, conn,
                 -1, TimeUnit.MILLISECONDS));
+        entry.markRouteComplete();
 
         Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
         Mockito.when(future.get(1, TimeUnit.SECONDS)).thenReturn(entry);



Mime
View raw message