hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject [2/6] httpcomponents-client git commit: Upgraded HttpCore to version 5.0-alpha4
Date Fri, 01 Sep 2017 18:15:26 GMT
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1eb22180/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java
index f227096..f4ce0a6 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java
@@ -44,12 +44,15 @@ import org.apache.hc.core5.concurrent.Cancellable;
 import org.apache.hc.core5.concurrent.ComplexFuture;
 import org.apache.hc.core5.concurrent.FutureCallback;
 import org.apache.hc.core5.function.Callback;
+import org.apache.hc.core5.http.EntityDetails;
+import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.http.HttpRequest;
 import org.apache.hc.core5.http.nio.AsyncClientEndpoint;
 import org.apache.hc.core5.http.nio.AsyncClientExchangeHandler;
 import org.apache.hc.core5.http.nio.AsyncRequestProducer;
 import org.apache.hc.core5.http.nio.AsyncResponseConsumer;
+import org.apache.hc.core5.http.nio.RequestChannel;
 import org.apache.hc.core5.http.nio.command.ShutdownCommand;
 import org.apache.hc.core5.http.protocol.HttpContext;
 import org.apache.hc.core5.http2.HttpVersionPolicy;
@@ -57,11 +60,11 @@ import org.apache.hc.core5.io.ShutdownType;
 import org.apache.hc.core5.reactor.DefaultConnectingIOReactor;
 import org.apache.hc.core5.reactor.IOEventHandlerFactory;
 import org.apache.hc.core5.reactor.IOReactorConfig;
-import org.apache.hc.core5.reactor.IOReactorException;
 import org.apache.hc.core5.reactor.IOSession;
 import org.apache.hc.core5.util.Args;
 import org.apache.hc.core5.util.Asserts;
 import org.apache.hc.core5.util.TimeValue;
+import org.apache.hc.core5.util.Timeout;
 
 public class MinimalHttpAsyncClient extends AbstractHttpAsyncClientBase {
 
@@ -75,11 +78,13 @@ public class MinimalHttpAsyncClient extends AbstractHttpAsyncClientBase {
             final IOReactorConfig reactorConfig,
             final ThreadFactory threadFactory,
             final ThreadFactory workerThreadFactory,
-            final AsyncClientConnectionManager connmgr) throws IOReactorException {
+            final AsyncClientConnectionManager connmgr) {
         super(new DefaultConnectingIOReactor(
                 eventHandlerFactory,
                 reactorConfig,
                 workerThreadFactory,
+                null,
+                null,
                 new Callback<IOSession>() {
 
                     @Override
@@ -96,7 +101,7 @@ public class MinimalHttpAsyncClient extends AbstractHttpAsyncClientBase {
 
     private Future<AsyncConnectionEndpoint> leaseEndpoint(
             final HttpHost host,
-            final TimeValue connectTimeout,
+            final Timeout connectTimeout,
             final HttpClientContext clientContext,
             final FutureCallback<AsyncConnectionEndpoint> callback) {
         final ComplexFuture<AsyncConnectionEndpoint> resultFuture = new ComplexFuture<>(callback);
@@ -197,8 +202,6 @@ public class MinimalHttpAsyncClient extends AbstractHttpAsyncClientBase {
             final HttpContext context,
             final FutureCallback<T> callback) {
         ensureRunning();
-        final HttpRequest request = requestProducer.produceRequest();
-        final HttpHost target = new HttpHost(request.getAuthority(), request.getScheme());
         final HttpClientContext clientContext = HttpClientContext.adapt(context);
         RequestConfig requestConfig = null;
         if (requestProducer instanceof Configurable) {
@@ -210,58 +213,73 @@ public class MinimalHttpAsyncClient extends AbstractHttpAsyncClientBase {
             requestConfig = clientContext.getRequestConfig();
         }
         final ComplexFuture<T> resultFuture = new ComplexFuture<>(callback);
-        final Future<AsyncConnectionEndpoint> leaseFuture = leaseEndpoint(target, requestConfig.getConnectTimeout(), clientContext,
-                new FutureCallback<AsyncConnectionEndpoint>() {
+        try {
+            final Timeout connectTimeout = requestConfig.getConnectTimeout();
+            requestProducer.sendRequest(new RequestChannel() {
 
-                    @Override
-                    public void completed(final AsyncConnectionEndpoint connectionEndpoint) {
-                        final InternalAsyncClientEndpoint endpoint = new InternalAsyncClientEndpoint(connectionEndpoint);
-                        endpoint.execute(requestProducer, responseConsumer, clientContext, new FutureCallback<T>() {
-
-                            @Override
-                            public void completed(final T result) {
-                                endpoint.releaseAndReuse();
-                                resultFuture.completed(result);
-                            }
-
-                            @Override
-                            public void failed(final Exception ex) {
-                                endpoint.releaseAndDiscard();
-                                resultFuture.failed(ex);
-                            }
-
-                            @Override
-                            public void cancelled() {
-                                endpoint.releaseAndDiscard();
-                                resultFuture.cancel();
-                            }
-
-                        });
-                        resultFuture.setDependency(new Cancellable() {
-
-                            @Override
-                            public boolean cancel() {
-                                final boolean active = !endpoint.isReleased();
-                                endpoint.releaseAndDiscard();
-                                return active;
-                            }
-
-                        });
+                @Override
+                public void sendRequest(
+                        final HttpRequest request,
+                        final EntityDetails entityDetails) throws HttpException, IOException {
+                    final HttpHost target = new HttpHost(request.getAuthority(), request.getScheme());
+                    final Future<AsyncConnectionEndpoint> leaseFuture = leaseEndpoint(target, connectTimeout, clientContext,
+                            new FutureCallback<AsyncConnectionEndpoint>() {
+
+                                @Override
+                                public void completed(final AsyncConnectionEndpoint connectionEndpoint) {
+                                    final InternalAsyncClientEndpoint endpoint = new InternalAsyncClientEndpoint(connectionEndpoint);
+                                    endpoint.execute(requestProducer, responseConsumer, clientContext, new FutureCallback<T>() {
 
-                    }
+                                        @Override
+                                        public void completed(final T result) {
+                                            endpoint.releaseAndReuse();
+                                            resultFuture.completed(result);
+                                        }
 
-                    @Override
-                    public void failed(final Exception ex) {
-                        resultFuture.failed(ex);
-                    }
+                                        @Override
+                                        public void failed(final Exception ex) {
+                                            endpoint.releaseAndDiscard();
+                                            resultFuture.failed(ex);
+                                        }
 
-                    @Override
-                    public void cancelled() {
-                        resultFuture.cancel();
-                    }
+                                        @Override
+                                        public void cancelled() {
+                                            endpoint.releaseAndDiscard();
+                                            resultFuture.cancel();
+                                        }
 
-                });
-        resultFuture.setDependency(leaseFuture);
+                                    });
+                                    resultFuture.setDependency(new Cancellable() {
+
+                                        @Override
+                                        public boolean cancel() {
+                                            final boolean active = !endpoint.isReleased();
+                                            endpoint.releaseAndDiscard();
+                                            return active;
+                                        }
+
+                                    });
+
+                                }
+
+                                @Override
+                                public void failed(final Exception ex) {
+                                    resultFuture.failed(ex);
+                                }
+
+                                @Override
+                                public void cancelled() {
+                                    resultFuture.cancel();
+                                }
+
+                            });
+                    resultFuture.setDependency(leaseFuture);
+                }
+            });
+
+        } catch (final HttpException | IOException ex) {
+            resultFuture.failed(ex);
+        }
         return resultFuture;
     }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1eb22180/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java
index 429677a..4dca6a7 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java
@@ -65,8 +65,8 @@ import org.apache.hc.core5.http.protocol.HttpContext;
 import org.apache.hc.core5.io.ShutdownType;
 import org.apache.hc.core5.pool.ConnPoolControl;
 import org.apache.hc.core5.pool.ConnPoolListener;
-import org.apache.hc.core5.pool.ConnPoolPolicy;
 import org.apache.hc.core5.pool.PoolEntry;
+import org.apache.hc.core5.pool.PoolReusePolicy;
 import org.apache.hc.core5.pool.PoolStats;
 import org.apache.hc.core5.pool.StrictConnPool;
 import org.apache.hc.core5.util.Args;
@@ -128,7 +128,7 @@ public class PoolingHttpClientConnectionManager
     }
 
     public PoolingHttpClientConnectionManager(final TimeValue timeToLive) {
-        this(getDefaultRegistry(), null, null ,null, ConnPoolPolicy.LIFO, null, timeToLive);
+        this(getDefaultRegistry(), null, null ,null, PoolReusePolicy.LIFO, null, timeToLive);
     }
 
     public PoolingHttpClientConnectionManager(
@@ -157,7 +157,7 @@ public class PoolingHttpClientConnectionManager
             final Registry<ConnectionSocketFactory> socketFactoryRegistry,
             final HttpConnectionFactory<ManagedHttpClientConnection> connFactory,
             final DnsResolver dnsResolver) {
-        this(socketFactoryRegistry, connFactory, null, dnsResolver, ConnPoolPolicy.LIFO, null, TimeValue.NEG_ONE_MILLISECONDS);
+        this(socketFactoryRegistry, connFactory, null, dnsResolver, PoolReusePolicy.LIFO, null, TimeValue.NEG_ONE_MILLISECONDS);
     }
 
     public PoolingHttpClientConnectionManager(
@@ -165,24 +165,24 @@ public class PoolingHttpClientConnectionManager
             final HttpConnectionFactory<ManagedHttpClientConnection> connFactory,
             final SchemePortResolver schemePortResolver,
             final DnsResolver dnsResolver,
-            final ConnPoolPolicy connPoolPolicy,
+            final PoolReusePolicy poolReusePolicy,
             final ConnPoolListener<HttpRoute> connPoolListener,
             final TimeValue timeToLive) {
         this(new DefaultHttpClientConnectionOperator(socketFactoryRegistry, schemePortResolver, dnsResolver),
-            connFactory, connPoolPolicy, connPoolListener, timeToLive);
+            connFactory, poolReusePolicy, connPoolListener, timeToLive);
     }
 
     public PoolingHttpClientConnectionManager(
             final HttpClientConnectionOperator httpClientConnectionOperator,
             final HttpConnectionFactory<ManagedHttpClientConnection> connFactory,
-            final ConnPoolPolicy connPoolPolicy,
+            final PoolReusePolicy poolReusePolicy,
             final ConnPoolListener<HttpRoute> connPoolListener,
             final TimeValue timeToLive) {
         super();
         this.connectionOperator = Args.notNull(httpClientConnectionOperator, "Connection operator");
         this.connFactory = connFactory != null ? connFactory : ManagedHttpClientConnectionFactory.INSTANCE;
         this.pool = new StrictConnPool<>(
-                DEFAULT_MAX_CONNECTIONS_PER_ROUTE, DEFAULT_MAX_TOTAL_CONNECTIONS, timeToLive, connPoolPolicy, connPoolListener);
+                DEFAULT_MAX_CONNECTIONS_PER_ROUTE, DEFAULT_MAX_TOTAL_CONNECTIONS, timeToLive, poolReusePolicy, connPoolListener);
         this.closed = new AtomicBoolean(false);
     }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1eb22180/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManagerBuilder.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManagerBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManagerBuilder.java
index 5a3c859..76c36b3 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManagerBuilder.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManagerBuilder.java
@@ -39,7 +39,7 @@ import org.apache.hc.core5.http.config.RegistryBuilder;
 import org.apache.hc.core5.http.config.SocketConfig;
 import org.apache.hc.core5.http.io.HttpConnectionFactory;
 import org.apache.hc.core5.pool.ConnPoolListener;
-import org.apache.hc.core5.pool.ConnPoolPolicy;
+import org.apache.hc.core5.pool.PoolReusePolicy;
 import org.apache.hc.core5.util.TimeValue;
 
 /**
@@ -74,7 +74,7 @@ public class PoolingHttpClientConnectionManagerBuilder {
     private LayeredConnectionSocketFactory sslSocketFactory;
     private SchemePortResolver schemePortResolver;
     private DnsResolver dnsResolver;
-    private ConnPoolPolicy connPoolPolicy;
+    private PoolReusePolicy poolReusePolicy;
     private ConnPoolListener<HttpRoute> connPoolListener;
     private SocketConfig defaultSocketConfig;
 
@@ -129,10 +129,10 @@ public class PoolingHttpClientConnectionManagerBuilder {
     }
 
     /**
-     * Assigns {@link ConnPoolPolicy} value.
+     * Assigns {@link PoolReusePolicy} value.
      */
-    public final PoolingHttpClientConnectionManagerBuilder setConnPoolPolicy(final ConnPoolPolicy connPoolPolicy) {
-        this.connPoolPolicy = connPoolPolicy;
+    public final PoolingHttpClientConnectionManagerBuilder setConnPoolPolicy(final PoolReusePolicy poolReusePolicy) {
+        this.poolReusePolicy = poolReusePolicy;
         return this;
     }
 
@@ -209,7 +209,7 @@ public class PoolingHttpClientConnectionManagerBuilder {
                 connectionFactory,
                 schemePortResolver,
                 dnsResolver,
-                connPoolPolicy,
+                poolReusePolicy,
                 connPoolListener,
                 timeToLive != null ? timeToLive : TimeValue.NEG_ONE_MILLISECONDS);
         poolingmgr.setValidateAfterInactivity(this.validateAfterInactivity);

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1eb22180/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/AsyncClientConnectionOperator.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/AsyncClientConnectionOperator.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/AsyncClientConnectionOperator.java
index b2b764a..04c07e2 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/AsyncClientConnectionOperator.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/AsyncClientConnectionOperator.java
@@ -27,15 +27,14 @@
 
 package org.apache.hc.client5.http.impl.nio;
 
+import java.io.IOException;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.SocketAddress;
-import java.net.SocketException;
 import java.net.UnknownHostException;
 import java.util.concurrent.Future;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import org.apache.hc.client5.http.ConnectTimeoutException;
 import org.apache.hc.client5.http.DnsResolver;
 import org.apache.hc.client5.http.HttpHostConnectException;
 import org.apache.hc.client5.http.SchemePortResolver;
@@ -48,9 +47,7 @@ import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.http.config.Lookup;
 import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
 import org.apache.hc.core5.reactor.ConnectionInitiator;
-import org.apache.hc.core5.reactor.SessionRequest;
-import org.apache.hc.core5.reactor.SessionRequestCallback;
-import org.apache.hc.core5.reactor.TlsCapableIOSession;
+import org.apache.hc.core5.reactor.IOSession;
 import org.apache.hc.core5.util.Args;
 import org.apache.hc.core5.util.TimeValue;
 
@@ -101,16 +98,16 @@ final class AsyncClientConnectionOperator {
             void executeNext() {
                 final int index = attempt.getAndIncrement();
                 final InetSocketAddress remoteAddress = new InetSocketAddress(remoteAddresses[index], port);
-                final SessionRequest sessionRequest = connectionInitiator.connect(
+                final Future<IOSession> sessionFuture = connectionInitiator.connect(
                         host,
                         remoteAddress,
                         localAddress,
+                        connectTimeout,
                         attachment,
-                        new SessionRequestCallback() {
+                        new FutureCallback<IOSession>() {
 
                             @Override
-                            public void completed(final SessionRequest request) {
-                                final TlsCapableIOSession session = request.getSession();
+                            public void completed(final IOSession session) {
                                 final ManagedAsyncClientConnection connection = new ManagedAsyncClientConnection(session);
                                 if (tlsStrategy != null) {
                                     tlsStrategy.upgrade(
@@ -118,33 +115,31 @@ final class AsyncClientConnectionOperator {
                                             host,
                                             session.getLocalAddress(),
                                             session.getRemoteAddress(),
-                                            request.getAttachment());
+                                            attachment);
                                 }
                                 future.completed(connection);
                             }
 
                             @Override
-                            public void failed(final SessionRequest request) {
+                            public void failed(final Exception cause) {
                                 if (attempt.get() >= remoteAddresses.length) {
-                                    future.failed(new HttpHostConnectException(request.getException(), host, remoteAddresses));
+                                    if (cause instanceof IOException) {
+                                        future.failed(new HttpHostConnectException((IOException) cause, host, remoteAddresses));
+                                    } else {
+                                        future.failed(cause);
+                                    }
                                 } else {
                                     executeNext();
                                 }
                             }
 
                             @Override
-                            public void timeout(final SessionRequest request) {
-                                future.failed(new ConnectTimeoutException(new SocketException(), host, remoteAddresses));
-                            }
-
-                            @Override
-                            public void cancelled(final SessionRequest request) {
+                            public void cancelled() {
                                 future.cancel();
                             }
 
                         });
-                future.setDependency(sessionRequest);
-                sessionRequest.setConnectTimeout(connectTimeout.toMillisIntBound());
+                future.setDependency(sessionFuture);
             }
 
             @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1eb22180/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/ManagedAsyncClientConnection.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/ManagedAsyncClientConnection.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/ManagedAsyncClientConnection.java
index 3998aee..ef8beba 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/ManagedAsyncClientConnection.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/ManagedAsyncClientConnection.java
@@ -43,7 +43,7 @@ import org.apache.hc.core5.http.nio.command.ShutdownCommand;
 import org.apache.hc.core5.io.ShutdownType;
 import org.apache.hc.core5.reactor.Command;
 import org.apache.hc.core5.reactor.IOEventHandler;
-import org.apache.hc.core5.reactor.TlsCapableIOSession;
+import org.apache.hc.core5.reactor.IOSession;
 import org.apache.hc.core5.reactor.ssl.SSLBufferManagement;
 import org.apache.hc.core5.reactor.ssl.SSLSessionInitializer;
 import org.apache.hc.core5.reactor.ssl.SSLSessionVerifier;
@@ -57,10 +57,10 @@ final class ManagedAsyncClientConnection implements Identifiable, HttpConnection
 
     private final Logger log = LogManager.getLogger(getClass());
 
-    private final TlsCapableIOSession ioSession;
+    private final IOSession ioSession;
     private final AtomicBoolean closed;
 
-    public ManagedAsyncClientConnection(final TlsCapableIOSession ioSession) {
+    public ManagedAsyncClientConnection(final IOSession ioSession) {
         this.ioSession = ioSession;
         this.closed = new AtomicBoolean();
     }
@@ -144,17 +144,21 @@ final class ManagedAsyncClientConnection implements Identifiable, HttpConnection
         if (log.isDebugEnabled()) {
             log.debug(getId() + ": start TLS");
         }
-        ioSession.startTls(sslContext, sslBufferManagement, initializer, verifier);
+        if (ioSession instanceof TransportSecurityLayer) {
+            ((TransportSecurityLayer) ioSession).startTls(sslContext, sslBufferManagement, initializer, verifier);
+        } else {
+            throw new UnsupportedOperationException("TLS upgrade not supported");
+        }
     }
 
     @Override
     public TlsDetails getTlsDetails() {
-        return ioSession.getTlsDetails();
+        return ioSession instanceof TransportSecurityLayer ? ((TransportSecurityLayer) ioSession).getTlsDetails() : null;
     }
 
     @Override
     public SSLSession getSSLSession() {
-        final TlsDetails tlsDetails = ioSession.getTlsDetails();
+        final TlsDetails tlsDetails = getTlsDetails();
         return tlsDetails != null ? tlsDetails.getSSLSession() : null;
     }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1eb22180/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
index 25dbae9..59d37bb 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
@@ -59,8 +59,8 @@ import org.apache.hc.core5.http2.nio.support.BasicPingHandler;
 import org.apache.hc.core5.io.ShutdownType;
 import org.apache.hc.core5.pool.ConnPoolControl;
 import org.apache.hc.core5.pool.ConnPoolListener;
-import org.apache.hc.core5.pool.ConnPoolPolicy;
 import org.apache.hc.core5.pool.PoolEntry;
+import org.apache.hc.core5.pool.PoolReusePolicy;
 import org.apache.hc.core5.pool.PoolStats;
 import org.apache.hc.core5.pool.StrictConnPool;
 import org.apache.hc.core5.reactor.ConnectionInitiator;
@@ -68,6 +68,7 @@ import org.apache.hc.core5.util.Args;
 import org.apache.hc.core5.util.Asserts;
 import org.apache.hc.core5.util.Identifiable;
 import org.apache.hc.core5.util.TimeValue;
+import org.apache.hc.core5.util.Timeout;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
@@ -105,10 +106,10 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
             final SchemePortResolver schemePortResolver,
             final DnsResolver dnsResolver,
             final TimeValue timeToLive,
-            final ConnPoolPolicy policy,
+            final PoolReusePolicy poolReusePolicy,
             final ConnPoolListener<HttpRoute> connPoolListener) {
         this.connectionOperator = new AsyncClientConnectionOperator(schemePortResolver, dnsResolver, tlsStrategyLookup);
-        this.pool = new StrictConnPool<>(20, 50, timeToLive, policy != null ? policy : ConnPoolPolicy.LIFO, connPoolListener);
+        this.pool = new StrictConnPool<>(20, 50, timeToLive, poolReusePolicy != null ? poolReusePolicy : PoolReusePolicy.LIFO, connPoolListener);
         this.closed = new AtomicBoolean(false);
     }
 
@@ -142,7 +143,7 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
     public Future<AsyncConnectionEndpoint> lease(
             final HttpRoute route,
             final Object state,
-            final TimeValue timeout,
+            final Timeout timeout,
             final FutureCallback<AsyncConnectionEndpoint> callback) {
         if (log.isDebugEnabled()) {
             log.debug("Connection request: " + ConnPoolSupport.formatStats(null, route, state, pool));
@@ -381,7 +382,7 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
 
     /**
      * Defines period of inactivity in milliseconds after which persistent connections must
-     * be re-validated prior to being {@link #lease(HttpRoute, Object, TimeValue,
+     * be re-validated prior to being {@link #lease(HttpRoute, Object, Timeout,
      * FutureCallback)} leased} to the consumer. Non-positive value passed
      * to this method disables connection validation. This check helps detect connections
      * that have become stale (half-closed) while kept inactive in the pool.

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1eb22180/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManagerBuilder.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManagerBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManagerBuilder.java
index 2af512c..9a840ad 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManagerBuilder.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManagerBuilder.java
@@ -27,6 +27,9 @@
 
 package org.apache.hc.client5.http.impl.nio;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
 import org.apache.hc.client5.http.DnsResolver;
 import org.apache.hc.client5.http.HttpRoute;
 import org.apache.hc.client5.http.SchemePortResolver;
@@ -34,12 +37,9 @@ import org.apache.hc.client5.http.ssl.H2TlsStrategy;
 import org.apache.hc.core5.http.config.RegistryBuilder;
 import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
 import org.apache.hc.core5.pool.ConnPoolListener;
-import org.apache.hc.core5.pool.ConnPoolPolicy;
+import org.apache.hc.core5.pool.PoolReusePolicy;
 import org.apache.hc.core5.util.TimeValue;
 
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
 /**
  * Builder for {@link PoolingAsyncClientConnectionManager} instances.
  * <p>
@@ -71,7 +71,7 @@ public class PoolingAsyncClientConnectionManagerBuilder {
     private TlsStrategy tlsStrategy;
     private SchemePortResolver schemePortResolver;
     private DnsResolver dnsResolver;
-    private ConnPoolPolicy connPoolPolicy;
+    private PoolReusePolicy poolReusePolicy;
     private ConnPoolListener<HttpRoute> connPoolListener;
 
     private boolean systemProperties;
@@ -116,10 +116,10 @@ public class PoolingAsyncClientConnectionManagerBuilder {
     }
 
     /**
-     * Assigns {@link ConnPoolPolicy} value.
+     * Assigns {@link PoolReusePolicy} value.
      */
-    public final PoolingAsyncClientConnectionManagerBuilder setConnPoolPolicy(final ConnPoolPolicy connPoolPolicy) {
-        this.connPoolPolicy = connPoolPolicy;
+    public final PoolingAsyncClientConnectionManagerBuilder setConnPoolPolicy(final PoolReusePolicy connPoolPolicy) {
+        this.poolReusePolicy = poolReusePolicy;
         return this;
     }
 
@@ -184,7 +184,7 @@ public class PoolingAsyncClientConnectionManagerBuilder {
                 schemePortResolver,
                 dnsResolver,
                 timeToLive,
-                connPoolPolicy,
+                poolReusePolicy,
                 connPoolListener);
         poolingmgr.setValidateAfterInactivity(this.validateAfterInactivity);
         if (maxConnTotal > 0) {

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1eb22180/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/AbstractHttpClientResponseHandler.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/AbstractHttpClientResponseHandler.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/AbstractHttpClientResponseHandler.java
new file mode 100644
index 0000000..8bceb6d
--- /dev/null
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/AbstractHttpClientResponseHandler.java
@@ -0,0 +1,79 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.hc.client5.http.impl.sync;
+
+import java.io.IOException;
+
+import org.apache.hc.client5.http.protocol.HttpResponseException;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.io.HttpClientResponseHandler;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+
+/**
+ * A generic {@link HttpClientResponseHandler} that works with the response entity
+ * for successful (2xx) responses. If the response code was &gt;= 300, the response
+ * body is consumed and an {@link HttpResponseException} is thrown.
+ * <p>
+ * If this is used with
+ * {@link org.apache.hc.client5.http.sync.HttpClient#execute(org.apache.hc.core5.http.ClassicHttpRequest,
+ * HttpClientResponseHandler)},
+ * HttpClient may handle redirects (3xx responses) internally.
+ * </p>
+ *
+ * @since 4.4
+ */
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
+public abstract class AbstractHttpClientResponseHandler<T> implements HttpClientResponseHandler<T> {
+
+    /**
+     * Read the entity from the response body and pass it to the entity handler
+     * method if the response was successful (a 2xx status code). If no response
+     * body exists, this returns null. If the response was unsuccessful (&gt;= 300
+     * status code), throws an {@link HttpResponseException}.
+     */
+    @Override
+    public T handleResponse(final ClassicHttpResponse response) throws IOException {
+        final HttpEntity entity = response.getEntity();
+        if (response.getCode() >= HttpStatus.SC_REDIRECTION) {
+            EntityUtils.consume(entity);
+            throw new HttpResponseException(response.getCode(), response.getReasonPhrase());
+        }
+        return entity == null ? null : handleEntity(entity);
+    }
+
+    /**
+     * Handle the response entity and transform it into the actual response
+     * object.
+     */
+    public abstract T handleEntity(HttpEntity entity) throws IOException;
+
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1eb22180/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/AbstractResponseHandler.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/AbstractResponseHandler.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/AbstractResponseHandler.java
deleted file mode 100644
index 00ba583..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/AbstractResponseHandler.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-package org.apache.hc.client5.http.impl.sync;
-
-import java.io.IOException;
-
-import org.apache.hc.client5.http.protocol.HttpResponseException;
-import org.apache.hc.core5.annotation.Contract;
-import org.apache.hc.core5.annotation.ThreadingBehavior;
-import org.apache.hc.core5.http.ClassicHttpResponse;
-import org.apache.hc.core5.http.HttpEntity;
-import org.apache.hc.core5.http.HttpStatus;
-import org.apache.hc.core5.http.io.ResponseHandler;
-import org.apache.hc.core5.http.io.entity.EntityUtils;
-
-/**
- * A generic {@link ResponseHandler} that works with the response entity
- * for successful (2xx) responses. If the response code was &gt;= 300, the response
- * body is consumed and an {@link HttpResponseException} is thrown.
- * <p>
- * If this is used with
- * {@link org.apache.hc.client5.http.sync.HttpClient#execute(org.apache.hc.core5.http.ClassicHttpRequest,
- * ResponseHandler)},
- * HttpClient may handle redirects (3xx responses) internally.
- * </p>
- *
- * @since 4.4
- */
-@Contract(threading = ThreadingBehavior.IMMUTABLE)
-public abstract class AbstractResponseHandler<T> implements ResponseHandler<T> {
-
-    /**
-     * Read the entity from the response body and pass it to the entity handler
-     * method if the response was successful (a 2xx status code). If no response
-     * body exists, this returns null. If the response was unsuccessful (&gt;= 300
-     * status code), throws an {@link HttpResponseException}.
-     */
-    @Override
-    public T handleResponse(final ClassicHttpResponse response) throws IOException {
-        final HttpEntity entity = response.getEntity();
-        if (response.getCode() >= HttpStatus.SC_REDIRECTION) {
-            EntityUtils.consume(entity);
-            throw new HttpResponseException(response.getCode(), response.getReasonPhrase());
-        }
-        return entity == null ? null : handleEntity(entity);
-    }
-
-    /**
-     * Handle the response entity and transform it into the actual response
-     * object.
-     */
-    public abstract T handleEntity(HttpEntity entity) throws IOException;
-
-}

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1eb22180/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/BasicHttpClientResponseHandler.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/BasicHttpClientResponseHandler.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/BasicHttpClientResponseHandler.java
new file mode 100644
index 0000000..d435262
--- /dev/null
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/BasicHttpClientResponseHandler.java
@@ -0,0 +1,73 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.hc.client5.http.impl.sync;
+
+import java.io.IOException;
+
+import org.apache.hc.client5.http.protocol.ClientProtocolException;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.ParseException;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+
+/**
+ * A {@link org.apache.hc.core5.http.io.ResponseHandler} that returns the response body as a String
+ * for successful (2xx) responses. If the response code was &gt;= 300, the response
+ * body is consumed and an {@link org.apache.hc.client5.http.protocol.HttpResponseException} is thrown.
+ * <p>
+ * If this is used with
+ * {@link org.apache.hc.client5.http.sync.HttpClient#execute(
+ *  org.apache.hc.core5.http.ClassicHttpRequest, org.apache.hc.core5.http.io.ResponseHandler)},
+ * HttpClient may handle redirects (3xx responses) internally.
+ * </p>
+ *
+ * @since 4.0
+ */
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
+public class BasicHttpClientResponseHandler extends AbstractHttpClientResponseHandler<String> {
+
+    /**
+     * Returns the entity as a body as a String.
+     */
+    @Override
+    public String handleEntity(final HttpEntity entity) throws IOException {
+        try {
+            return EntityUtils.toString(entity);
+        } catch (final ParseException ex) {
+            throw new ClientProtocolException(ex);
+        }
+    }
+
+    @Override
+    public String handleResponse(final ClassicHttpResponse response) throws IOException {
+        return super.handleResponse(response);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1eb22180/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/BasicResponseHandler.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/BasicResponseHandler.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/BasicResponseHandler.java
deleted file mode 100644
index 34f6e2c..0000000
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/BasicResponseHandler.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-package org.apache.hc.client5.http.impl.sync;
-
-import java.io.IOException;
-
-import org.apache.hc.client5.http.protocol.ClientProtocolException;
-import org.apache.hc.core5.annotation.Contract;
-import org.apache.hc.core5.annotation.ThreadingBehavior;
-import org.apache.hc.core5.http.ClassicHttpResponse;
-import org.apache.hc.core5.http.HttpEntity;
-import org.apache.hc.core5.http.ParseException;
-import org.apache.hc.core5.http.io.entity.EntityUtils;
-
-/**
- * A {@link org.apache.hc.core5.http.io.ResponseHandler} that returns the response body as a String
- * for successful (2xx) responses. If the response code was &gt;= 300, the response
- * body is consumed and an {@link org.apache.hc.client5.http.protocol.HttpResponseException} is thrown.
- * <p>
- * If this is used with
- * {@link org.apache.hc.client5.http.sync.HttpClient#execute(
- *  org.apache.hc.core5.http.ClassicHttpRequest, org.apache.hc.core5.http.io.ResponseHandler)},
- * HttpClient may handle redirects (3xx responses) internally.
- * </p>
- *
- * @since 4.0
- */
-@Contract(threading = ThreadingBehavior.IMMUTABLE)
-public class BasicResponseHandler extends AbstractResponseHandler<String> {
-
-    /**
-     * Returns the entity as a body as a String.
-     */
-    @Override
-    public String handleEntity(final HttpEntity entity) throws IOException {
-        try {
-            return EntityUtils.toString(entity);
-        } catch (final ParseException ex) {
-            throw new ClientProtocolException(ex);
-        }
-    }
-
-    @Override
-    public String handleResponse(final ClassicHttpResponse response) throws IOException {
-        return super.handleResponse(response);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1eb22180/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/CloseableHttpClient.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/CloseableHttpClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/CloseableHttpClient.java
index 9a28701..17f4777 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/CloseableHttpClient.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/CloseableHttpClient.java
@@ -41,7 +41,7 @@ import org.apache.hc.core5.http.ClassicHttpRequest;
 import org.apache.hc.core5.http.HttpEntity;
 import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.io.ResponseHandler;
+import org.apache.hc.core5.http.io.HttpClientResponseHandler;
 import org.apache.hc.core5.http.io.entity.EntityUtils;
 import org.apache.hc.core5.http.protocol.HttpContext;
 import org.apache.hc.core5.util.Args;
@@ -126,11 +126,11 @@ public abstract class CloseableHttpClient implements HttpClient, Closeable {
      * response using the given response handler. The content entity associated
      * with the response is fully consumed and the underlying connection is
      * released back to the connection manager automatically in all cases
-     * relieving individual {@link ResponseHandler}s from having to manage
+     * relieving individual {@link HttpClientResponseHandler}s from having to manage
      * resource deallocation internally.
      *
      * @param request   the request to execute
-     * @param responseHandler the response handler
+     * @param HttpClientResponseHandler the response handler
      *
      * @return  the response object as generated by the response handler.
      * @throws IOException in case of a problem or the connection was aborted
@@ -138,8 +138,8 @@ public abstract class CloseableHttpClient implements HttpClient, Closeable {
      */
     @Override
     public <T> T execute(final ClassicHttpRequest request,
-            final ResponseHandler<? extends T> responseHandler) throws IOException {
-        return execute(request, responseHandler, null);
+            final HttpClientResponseHandler<? extends T> HttpClientResponseHandler) throws IOException {
+        return execute(request, HttpClientResponseHandler, null);
     }
 
     /**
@@ -147,11 +147,11 @@ public abstract class CloseableHttpClient implements HttpClient, Closeable {
      * response using the given response handler. The content entity associated
      * with the response is fully consumed and the underlying connection is
      * released back to the connection manager automatically in all cases
-     * relieving individual {@link ResponseHandler}s from having to manage
+     * relieving individual {@link HttpClientResponseHandler}s from having to manage
      * resource deallocation internally.
      *
      * @param request   the request to execute
-     * @param responseHandler the response handler
+     * @param HttpClientResponseHandler the response handler
      * @param context   the context to use for the execution, or
      *                  {@code null} to use the default context
      *
@@ -161,10 +161,10 @@ public abstract class CloseableHttpClient implements HttpClient, Closeable {
      */
     @Override
     public <T> T execute(final ClassicHttpRequest request,
-            final ResponseHandler<? extends T> responseHandler, final HttpContext context)
+            final HttpClientResponseHandler<? extends T> HttpClientResponseHandler, final HttpContext context)
             throws IOException {
         final HttpHost target = determineTarget(request);
-        return execute(target, request, responseHandler, context);
+        return execute(target, request, HttpClientResponseHandler, context);
     }
 
     /**
@@ -172,7 +172,7 @@ public abstract class CloseableHttpClient implements HttpClient, Closeable {
      * response using the given response handler. The content entity associated
      * with the response is fully consumed and the underlying connection is
      * released back to the connection manager automatically in all cases
-     * relieving individual {@link ResponseHandler}s from having to manage
+     * relieving individual {@link HttpClientResponseHandler}s from having to manage
      * resource deallocation internally.
      *
      * @param target    the target host for the request.
@@ -180,7 +180,7 @@ public abstract class CloseableHttpClient implements HttpClient, Closeable {
      *                  if they can still determine a route, for example
      *                  to a default target or by inspecting the request.
      * @param request   the request to execute
-     * @param responseHandler the response handler
+     * @param HttpClientResponseHandler the response handler
      *
      * @return  the response object as generated by the response handler.
      * @throws IOException in case of a problem or the connection was aborted
@@ -188,8 +188,8 @@ public abstract class CloseableHttpClient implements HttpClient, Closeable {
      */
     @Override
     public <T> T execute(final HttpHost target, final ClassicHttpRequest request,
-            final ResponseHandler<? extends T> responseHandler) throws IOException {
-        return execute(target, request, responseHandler, null);
+            final HttpClientResponseHandler<? extends T> HttpClientResponseHandler) throws IOException {
+        return execute(target, request, HttpClientResponseHandler, null);
     }
 
     /**
@@ -197,7 +197,7 @@ public abstract class CloseableHttpClient implements HttpClient, Closeable {
      * response using the given response handler. The content entity associated
      * with the response is fully consumed and the underlying connection is
      * released back to the connection manager automatically in all cases
-     * relieving individual {@link ResponseHandler}s from having to manage
+     * relieving individual {@link HttpClientResponseHandler}s from having to manage
      * resource deallocation internally.
      *
      * @param target    the target host for the request.
@@ -205,7 +205,7 @@ public abstract class CloseableHttpClient implements HttpClient, Closeable {
      *                  if they can still determine a route, for example
      *                  to a default target or by inspecting the request.
      * @param request   the request to execute
-     * @param responseHandler the response handler
+     * @param HttpClientResponseHandler the response handler
      * @param context   the context to use for the execution, or
      *                  {@code null} to use the default context
      *
@@ -215,12 +215,12 @@ public abstract class CloseableHttpClient implements HttpClient, Closeable {
      */
     @Override
     public <T> T execute(final HttpHost target, final ClassicHttpRequest request,
-            final ResponseHandler<? extends T> responseHandler, final HttpContext context) throws IOException {
-        Args.notNull(responseHandler, "Response handler");
+            final HttpClientResponseHandler<? extends T> HttpClientResponseHandler, final HttpContext context) throws IOException {
+        Args.notNull(HttpClientResponseHandler, "Response handler");
 
         try (final CloseableHttpResponse response = execute(target, request, context)) {
             try {
-                final T result = responseHandler.handleResponse(response);
+                final T result = HttpClientResponseHandler.handleResponse(response);
                 final HttpEntity entity = response.getEntity();
                 EntityUtils.consume(entity);
                 return result;

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1eb22180/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/FutureRequestExecutionService.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/FutureRequestExecutionService.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/FutureRequestExecutionService.java
index 7601d74..acd3f49 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/FutureRequestExecutionService.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/FutureRequestExecutionService.java
@@ -36,7 +36,7 @@ import org.apache.hc.core5.annotation.Contract;
 import org.apache.hc.core5.annotation.ThreadingBehavior;
 import org.apache.hc.core5.concurrent.FutureCallback;
 import org.apache.hc.core5.http.ClassicHttpRequest;
-import org.apache.hc.core5.http.io.ResponseHandler;
+import org.apache.hc.core5.http.io.HttpClientResponseHandler;
 import org.apache.hc.core5.http.protocol.HttpContext;
 
 /**
@@ -78,15 +78,15 @@ public class FutureRequestExecutionService implements Closeable {
      *
      * @param request
      *            request to execute
-     * @param responseHandler
+     * @param HttpClientResponseHandler
      *            handler that will process the response.
      * @return HttpAsyncClientFutureTask for the scheduled request.
      */
     public <T> HttpRequestFutureTask<T> execute(
             final ClassicHttpRequest request,
             final HttpContext context,
-            final ResponseHandler<T> responseHandler) {
-        return execute(request, context, responseHandler, null);
+            final HttpClientResponseHandler<T> HttpClientResponseHandler) {
+        return execute(request, context, HttpClientResponseHandler, null);
     }
 
     /**
@@ -98,7 +98,7 @@ public class FutureRequestExecutionService implements Closeable {
      *            request to execute
      * @param context
      *            optional context; use null if not needed.
-     * @param responseHandler
+     * @param HttpClientResponseHandler
      *            handler that will process the response.
      * @param callback
      *            callback handler that will be called when the request is scheduled,
@@ -108,14 +108,14 @@ public class FutureRequestExecutionService implements Closeable {
     public <T> HttpRequestFutureTask<T> execute(
             final ClassicHttpRequest request,
             final HttpContext context,
-            final ResponseHandler<T> responseHandler,
+            final HttpClientResponseHandler<T> HttpClientResponseHandler,
             final FutureCallback<T> callback) {
         if(closed.get()) {
             throw new IllegalStateException("Close has been called on this httpclient instance.");
         }
         metrics.getScheduledConnections().incrementAndGet();
         final HttpRequestTaskCallable<T> callable = new HttpRequestTaskCallable<>(
-                httpclient, request, context, responseHandler, callback, metrics);
+                httpclient, request, context, HttpClientResponseHandler, callback, metrics);
         final HttpRequestFutureTask<T> httpRequestFutureTask = new HttpRequestFutureTask<>(
                 request, callable);
         executorService.execute(httpRequestFutureTask);

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1eb22180/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/HttpClientBuilder.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/HttpClientBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/HttpClientBuilder.java
index af94d36..113d107 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/HttpClientBuilder.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/HttpClientBuilder.java
@@ -53,7 +53,6 @@ import org.apache.hc.client5.http.impl.DefaultConnectionKeepAliveStrategy;
 import org.apache.hc.client5.http.impl.DefaultSchemePortResolver;
 import org.apache.hc.client5.http.impl.DefaultUserTokenHandler;
 import org.apache.hc.client5.http.impl.IdleConnectionEvictor;
-import org.apache.hc.client5.http.impl.NamedElementChain;
 import org.apache.hc.client5.http.impl.NoopUserTokenHandler;
 import org.apache.hc.client5.http.impl.auth.BasicSchemeFactory;
 import org.apache.hc.client5.http.impl.auth.CredSspSchemeFactory;
@@ -93,6 +92,7 @@ import org.apache.hc.core5.http.HttpRequestInterceptor;
 import org.apache.hc.core5.http.HttpResponse;
 import org.apache.hc.core5.http.HttpResponseInterceptor;
 import org.apache.hc.core5.http.config.Lookup;
+import org.apache.hc.core5.http.config.NamedElementChain;
 import org.apache.hc.core5.http.config.Registry;
 import org.apache.hc.core5.http.config.RegistryBuilder;
 import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy;

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1eb22180/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/HttpRequestTaskCallable.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/HttpRequestTaskCallable.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/HttpRequestTaskCallable.java
index 695727d..ac7696b 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/HttpRequestTaskCallable.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/HttpRequestTaskCallable.java
@@ -32,7 +32,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import org.apache.hc.client5.http.sync.HttpClient;
 import org.apache.hc.core5.concurrent.FutureCallback;
 import org.apache.hc.core5.http.ClassicHttpRequest;
-import org.apache.hc.core5.http.io.ResponseHandler;
+import org.apache.hc.core5.http.io.HttpClientResponseHandler;
 import org.apache.hc.core5.http.protocol.HttpContext;
 
 class HttpRequestTaskCallable<V> implements Callable<V> {
@@ -46,7 +46,7 @@ class HttpRequestTaskCallable<V> implements Callable<V> {
     private long ended = -1;
 
     private final HttpContext context;
-    private final ResponseHandler<V> responseHandler;
+    private final HttpClientResponseHandler<V> responseHandler;
     private final FutureCallback<V> callback;
 
     private final FutureRequestExecutionMetrics metrics;
@@ -55,7 +55,7 @@ class HttpRequestTaskCallable<V> implements Callable<V> {
             final HttpClient httpClient,
             final ClassicHttpRequest request,
             final HttpContext context,
-            final ResponseHandler<V> responseHandler,
+            final HttpClientResponseHandler<V> responseHandler,
             final FutureCallback<V> callback,
             final FutureRequestExecutionMetrics metrics) {
         this.httpclient = httpClient;

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1eb22180/httpclient5/src/main/java/org/apache/hc/client5/http/nio/AsyncClientConnectionManager.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/nio/AsyncClientConnectionManager.java b/httpclient5/src/main/java/org/apache/hc/client5/http/nio/AsyncClientConnectionManager.java
index 6318989..1b119bf 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/nio/AsyncClientConnectionManager.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/nio/AsyncClientConnectionManager.java
@@ -34,6 +34,7 @@ import org.apache.hc.core5.concurrent.FutureCallback;
 import org.apache.hc.core5.http.protocol.HttpContext;
 import org.apache.hc.core5.reactor.ConnectionInitiator;
 import org.apache.hc.core5.util.TimeValue;
+import org.apache.hc.core5.util.Timeout;
 
 /**
  * Represents a manager of persistent non-blocking client connections.
@@ -76,7 +77,7 @@ public interface AsyncClientConnectionManager extends Closeable {
     Future<AsyncConnectionEndpoint> lease(
             HttpRoute route,
             Object state,
-            TimeValue timeout,
+            Timeout timeout,
             FutureCallback<AsyncConnectionEndpoint> callback);
 
     /**

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1eb22180/httpclient5/src/main/java/org/apache/hc/client5/http/sync/HttpClient.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/sync/HttpClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/sync/HttpClient.java
index 26fb3b1..befa7ae 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/sync/HttpClient.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/sync/HttpClient.java
@@ -33,7 +33,7 @@ import org.apache.hc.core5.http.ClassicHttpRequest;
 import org.apache.hc.core5.http.ClassicHttpResponse;
 import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.http.HttpResponse;
-import org.apache.hc.core5.http.io.ResponseHandler;
+import org.apache.hc.core5.http.io.HttpClientResponseHandler;
 import org.apache.hc.core5.http.protocol.HttpContext;
 
 /**
@@ -121,17 +121,17 @@ public interface HttpClient {
      * Implementing classes are required to ensure that the content entity
      * associated with the response is fully consumed and the underlying
      * connection is released back to the connection manager automatically
-     * in all cases relieving individual {@link ResponseHandler}s from
+     * in all cases relieving individual {@link HttpClientResponseHandler}s from
      * having to manage resource deallocation internally.
      * </p>
      *
      * @param request   the request to execute
-     * @param responseHandler the response handler
+     * @param HttpClientResponseHandler the response handler
      *
      * @return  the response object as generated by the response handler.
      * @throws IOException in case of a problem or the connection was aborted
      */
-    <T> T execute(ClassicHttpRequest request, ResponseHandler<? extends T> responseHandler) throws IOException;
+    <T> T execute(ClassicHttpRequest request, HttpClientResponseHandler<? extends T> HttpClientResponseHandler) throws IOException;
 
     /**
      * Executes HTTP request using the given context and processes the
@@ -140,19 +140,19 @@ public interface HttpClient {
      * Implementing classes are required to ensure that the content entity
      * associated with the response is fully consumed and the underlying
      * connection is released back to the connection manager automatically
-     * in all cases relieving individual {@link ResponseHandler}s from
+     * in all cases relieving individual {@link HttpClientResponseHandler}s from
      * having to manage resource deallocation internally.
      * </p>
      *
      * @param request   the request to execute
-     * @param responseHandler the response handler
+     * @param HttpClientResponseHandler the response handler
      * @param context   the context to use for the execution, or
      *                  {@code null} to use the default context
      *
      * @return  the response object as generated by the response handler.
      * @throws IOException in case of a problem or the connection was aborted
      */
-    <T> T execute(ClassicHttpRequest request, ResponseHandler<? extends T> responseHandler, HttpContext context) throws IOException;
+    <T> T execute(ClassicHttpRequest request, HttpClientResponseHandler<? extends T> HttpClientResponseHandler, HttpContext context) throws IOException;
 
     /**
      * Executes HTTP request to the target using the default context and
@@ -161,7 +161,7 @@ public interface HttpClient {
      * Implementing classes are required to ensure that the content entity
      * associated with the response is fully consumed and the underlying
      * connection is released back to the connection manager automatically
-     * in all cases relieving individual {@link ResponseHandler}s from
+     * in all cases relieving individual {@link HttpClientResponseHandler}s from
      * having to manage resource deallocation internally.
      * </p>
      *
@@ -170,12 +170,12 @@ public interface HttpClient {
      *                  if they can still determine a route, for example
      *                  to a default target or by inspecting the request.
      * @param request   the request to execute
-     * @param responseHandler the response handler
+     * @param HttpClientResponseHandler the response handler
      *
      * @return  the response object as generated by the response handler.
      * @throws IOException in case of a problem or the connection was aborted
      */
-    <T> T execute(HttpHost target, ClassicHttpRequest request, ResponseHandler<? extends T> responseHandler) throws IOException;
+    <T> T execute(HttpHost target, ClassicHttpRequest request, HttpClientResponseHandler<? extends T> HttpClientResponseHandler) throws IOException;
 
     /**
      * Executes HTTP request to the target using the given context and
@@ -184,7 +184,7 @@ public interface HttpClient {
      * Implementing classes are required to ensure that the content entity
      * associated with the response is fully consumed and the underlying
      * connection is released back to the connection manager automatically
-     * in all cases relieving individual {@link ResponseHandler}s from
+     * in all cases relieving individual {@link HttpClientResponseHandler}s from
      * having to manage resource deallocation internally.
      * </p>
      *
@@ -193,7 +193,7 @@ public interface HttpClient {
      *                  if they can still determine a route, for example
      *                  to a default target or by inspecting the request.
      * @param request   the request to execute
-     * @param responseHandler the response handler
+     * @param HttpClientResponseHandler the response handler
      * @param context   the context to use for the execution, or
      *                  {@code null} to use the default context
      *
@@ -203,7 +203,7 @@ public interface HttpClient {
     <T> T execute(
             HttpHost target,
             ClassicHttpRequest request,
-            ResponseHandler<? extends T> responseHandler,
+            HttpClientResponseHandler<? extends T> HttpClientResponseHandler,
             HttpContext context) throws IOException;
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1eb22180/httpclient5/src/main/java/org/apache/hc/client5/http/utils/URIUtils.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/utils/URIUtils.java b/httpclient5/src/main/java/org/apache/hc/client5/http/utils/URIUtils.java
index ba81be2..d22bbe3 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/utils/URIUtils.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/utils/URIUtils.java
@@ -77,7 +77,7 @@ public class URIUtils {
             uribuilder.setPort(target.getPort());
         } else {
             uribuilder.setScheme(null);
-            uribuilder.setHost(null);
+            uribuilder.setHost((String) null);
             uribuilder.setPort(-1);
         }
         if (dropFragment) {

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1eb22180/httpclient5/src/test/java/org/apache/hc/client5/http/config/TestRequestConfig.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/config/TestRequestConfig.java b/httpclient5/src/test/java/org/apache/hc/client5/http/config/TestRequestConfig.java
index fab90d8..36a8558 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/config/TestRequestConfig.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/config/TestRequestConfig.java
@@ -33,6 +33,7 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.util.TimeValue;
+import org.apache.hc.core5.util.Timeout;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -47,9 +48,9 @@ public class TestRequestConfig {
     @Test
     public void testDefaults() {
         final RequestConfig config = RequestConfig.DEFAULT;
-        Assert.assertEquals(TimeValue.NEG_ONE_MILLISECONDS, config.getSocketTimeout());
-        Assert.assertEquals(TimeValue.ofMinutes(3), config.getConnectTimeout());
-        Assert.assertEquals(TimeValue.ofMinutes(3), config.getConnectionRequestTimeout());
+        Assert.assertEquals(Timeout.ZERO_MILLISECONDS, config.getSocketTimeout());
+        Assert.assertEquals(Timeout.ofMinutes(3), config.getConnectTimeout());
+        Assert.assertEquals(Timeout.ofMinutes(3), config.getConnectionRequestTimeout());
         Assert.assertEquals(false, config.isExpectContinueEnabled());
         Assert.assertEquals(true, config.isAuthenticationEnabled());
         Assert.assertEquals(true, config.isRedirectsEnabled());

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1eb22180/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestAbstractHttpClientResponseHandler.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestAbstractHttpClientResponseHandler.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestAbstractHttpClientResponseHandler.java
new file mode 100644
index 0000000..44a48ba
--- /dev/null
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestAbstractHttpClientResponseHandler.java
@@ -0,0 +1,89 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.hc.client5.http.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.hc.client5.http.impl.sync.AbstractHttpClientResponseHandler;
+import org.apache.hc.client5.http.impl.sync.BasicHttpClientResponseHandler;
+import org.apache.hc.client5.http.protocol.HttpResponseException;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.StringEntity;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+/**
+ * Unit tests for {@link BasicHttpClientResponseHandler}.
+ */
+public class TestAbstractHttpClientResponseHandler {
+
+    @Test
+    public void testSuccessfulResponse() throws Exception {
+        final ClassicHttpResponse response = Mockito.mock(ClassicHttpResponse.class);
+        final HttpEntity entity = new StringEntity("42");
+        Mockito.when(response.getCode()).thenReturn(200);
+        Mockito.when(response.getEntity()).thenReturn(entity);
+
+        final AbstractHttpClientResponseHandler<Integer> handler = new AbstractHttpClientResponseHandler<Integer>() {
+
+          @Override
+          public Integer handleEntity(final HttpEntity entity) throws IOException {
+            return Integer.valueOf(new String(EntityUtils.toByteArray(entity)));
+          }
+        };
+        final Integer number = handler.handleResponse(response);
+        Assert.assertEquals(42, number.intValue());
+    }
+
+    @SuppressWarnings("boxing")
+    @Test
+    public void testUnsuccessfulResponse() throws Exception {
+        final InputStream instream = Mockito.mock(InputStream.class);
+        final HttpEntity entity = Mockito.mock(HttpEntity.class);
+        Mockito.when(entity.isStreaming()).thenReturn(true);
+        Mockito.when(entity.getContent()).thenReturn(instream);
+        final ClassicHttpResponse response = Mockito.mock(ClassicHttpResponse.class);
+        Mockito.when(response.getCode()).thenReturn(404);
+        Mockito.when(response.getEntity()).thenReturn(entity);
+
+        final BasicHttpClientResponseHandler handler = new BasicHttpClientResponseHandler();
+        try {
+            handler.handleResponse(response);
+            Assert.fail("HttpResponseException expected");
+        } catch (final HttpResponseException ex) {
+            Assert.assertEquals(404, ex.getStatusCode());
+        }
+        Mockito.verify(entity).getContent();
+        Mockito.verify(instream).close();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1eb22180/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestAbstractResponseHandler.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestAbstractResponseHandler.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestAbstractResponseHandler.java
deleted file mode 100644
index cb12818..0000000
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestAbstractResponseHandler.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-package org.apache.hc.client5.http.impl;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.hc.client5.http.impl.sync.AbstractResponseHandler;
-import org.apache.hc.client5.http.impl.sync.BasicResponseHandler;
-import org.apache.hc.client5.http.protocol.HttpResponseException;
-import org.apache.hc.core5.http.ClassicHttpResponse;
-import org.apache.hc.core5.http.HttpEntity;
-import org.apache.hc.core5.http.io.entity.EntityUtils;
-import org.apache.hc.core5.http.io.entity.StringEntity;
-import org.junit.Assert;
-import org.junit.Test;
-import org.mockito.Mockito;
-
-/**
- * Unit tests for {@link BasicResponseHandler}.
- */
-public class TestAbstractResponseHandler {
-
-    @Test
-    public void testSuccessfulResponse() throws Exception {
-        final ClassicHttpResponse response = Mockito.mock(ClassicHttpResponse.class);
-        final HttpEntity entity = new StringEntity("42");
-        Mockito.when(response.getCode()).thenReturn(200);
-        Mockito.when(response.getEntity()).thenReturn(entity);
-
-        final AbstractResponseHandler<Integer> handler = new AbstractResponseHandler<Integer>() {
-
-          @Override
-          public Integer handleEntity(final HttpEntity entity) throws IOException {
-            return Integer.valueOf(new String(EntityUtils.toByteArray(entity)));
-          }
-        };
-        final Integer number = handler.handleResponse(response);
-        Assert.assertEquals(42, number.intValue());
-    }
-
-    @SuppressWarnings("boxing")
-    @Test
-    public void testUnsuccessfulResponse() throws Exception {
-        final InputStream instream = Mockito.mock(InputStream.class);
-        final HttpEntity entity = Mockito.mock(HttpEntity.class);
-        Mockito.when(entity.isStreaming()).thenReturn(true);
-        Mockito.when(entity.getContent()).thenReturn(instream);
-        final ClassicHttpResponse response = Mockito.mock(ClassicHttpResponse.class);
-        Mockito.when(response.getCode()).thenReturn(404);
-        Mockito.when(response.getEntity()).thenReturn(entity);
-
-        final BasicResponseHandler handler = new BasicResponseHandler();
-        try {
-            handler.handleResponse(response);
-            Assert.fail("HttpResponseException expected");
-        } catch (final HttpResponseException ex) {
-            Assert.assertEquals(404, ex.getStatusCode());
-        }
-        Mockito.verify(entity).getContent();
-        Mockito.verify(instream).close();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1eb22180/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestBasicResponseHandler.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestBasicResponseHandler.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestBasicResponseHandler.java
index db8c1b7..f8d5abb 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestBasicResponseHandler.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestBasicResponseHandler.java
@@ -29,7 +29,7 @@ package org.apache.hc.client5.http.impl;
 
 import java.io.InputStream;
 
-import org.apache.hc.client5.http.impl.sync.BasicResponseHandler;
+import org.apache.hc.client5.http.impl.sync.BasicHttpClientResponseHandler;
 import org.apache.hc.client5.http.protocol.HttpResponseException;
 import org.apache.hc.core5.http.ClassicHttpResponse;
 import org.apache.hc.core5.http.HttpEntity;
@@ -39,7 +39,7 @@ import org.junit.Test;
 import org.mockito.Mockito;
 
 /**
- * Unit tests for {@link BasicResponseHandler}.
+ * Unit tests for {@link BasicHttpClientResponseHandler}.
  */
 @SuppressWarnings("boxing") // test code
 public class TestBasicResponseHandler {
@@ -51,7 +51,7 @@ public class TestBasicResponseHandler {
         Mockito.when(response.getCode()).thenReturn(200);
         Mockito.when(response.getEntity()).thenReturn(entity);
 
-        final BasicResponseHandler handler = new BasicResponseHandler();
+        final BasicHttpClientResponseHandler handler = new BasicHttpClientResponseHandler();
         final String s = handler.handleResponse(response);
         Assert.assertEquals("stuff", s);
     }
@@ -66,7 +66,7 @@ public class TestBasicResponseHandler {
         Mockito.when(response.getCode()).thenReturn(404);
         Mockito.when(response.getEntity()).thenReturn(entity);
 
-        final BasicResponseHandler handler = new BasicResponseHandler();
+        final BasicHttpClientResponseHandler handler = new BasicHttpClientResponseHandler();
         try {
             handler.handleResponse(response);
             Assert.fail("HttpResponseException expected");

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1eb22180/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestNamedElementChain.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestNamedElementChain.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestNamedElementChain.java
deleted file mode 100644
index fb48ca9..0000000
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestNamedElementChain.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-package org.apache.hc.client5.http.impl;
-
-import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Tests for {@link NamedElementChain}.
- */
-public class TestNamedElementChain {
-
-    @Test
-    public void testBasics() {
-        final NamedElementChain<Character> list = new NamedElementChain<>();
-        Assert.assertThat(list.getFirst(), CoreMatchers.nullValue());
-        Assert.assertThat(list.getLast(), CoreMatchers.nullValue());
-
-        final NamedElementChain<Character>.Node nodeA = list.addFirst('a', "a");
-
-        Assert.assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeA));
-        Assert.assertThat(list.getLast(), CoreMatchers.sameInstance(nodeA));
-
-        final NamedElementChain<Character>.Node nodeB = list.addLast('b', "b");
-
-        Assert.assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeA));
-        Assert.assertThat(list.getLast(), CoreMatchers.sameInstance(nodeB));
-
-        final NamedElementChain<Character>.Node nodeZ = list.addLast('z', "z");
-
-        Assert.assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeA));
-        Assert.assertThat(list.getLast(), CoreMatchers.sameInstance(nodeZ));
-
-        Assert.assertThat(nodeA.getPrevious(), CoreMatchers.nullValue());
-        Assert.assertThat(nodeA.getNext(), CoreMatchers.sameInstance(nodeB));
-        Assert.assertThat(nodeB.getPrevious(), CoreMatchers.sameInstance(nodeA));
-        Assert.assertThat(nodeB.getNext(), CoreMatchers.sameInstance(nodeZ));
-        Assert.assertThat(nodeZ.getPrevious(), CoreMatchers.sameInstance(nodeB));
-        Assert.assertThat(nodeZ.getNext(), CoreMatchers.nullValue());
-
-        final NamedElementChain<Character>.Node nodeD = list.addAfter("b", 'd', "d");
-        Assert.assertThat(nodeD.getPrevious(), CoreMatchers.sameInstance(nodeB));
-        Assert.assertThat(nodeD.getNext(), CoreMatchers.sameInstance(nodeZ));
-        Assert.assertThat(nodeB.getNext(), CoreMatchers.sameInstance(nodeD));
-        Assert.assertThat(nodeZ.getPrevious(), CoreMatchers.sameInstance(nodeD));
-
-        final NamedElementChain<Character>.Node nodeC = list.addBefore("d", 'c', "c");
-        Assert.assertThat(nodeC.getPrevious(), CoreMatchers.sameInstance(nodeB));
-        Assert.assertThat(nodeC.getNext(), CoreMatchers.sameInstance(nodeD));
-        Assert.assertThat(nodeB.getNext(), CoreMatchers.sameInstance(nodeC));
-        Assert.assertThat(nodeD.getPrevious(), CoreMatchers.sameInstance(nodeC));
-        Assert.assertThat(list.getSize(), CoreMatchers.equalTo(5));
-
-        Assert.assertThat(list.remove("a"), CoreMatchers.is(true));
-        Assert.assertThat(list.remove("z"), CoreMatchers.is(true));
-        Assert.assertThat(list.remove("c"), CoreMatchers.is(true));
-        Assert.assertThat(list.remove("c"), CoreMatchers.is(false));
-        Assert.assertThat(list.remove("blah"), CoreMatchers.is(false));
-
-        Assert.assertThat(list.getFirst(), CoreMatchers.sameInstance(nodeB));
-        Assert.assertThat(list.getLast(), CoreMatchers.sameInstance(nodeD));
-
-        Assert.assertThat(list.getSize(), CoreMatchers.equalTo(2));
-        Assert.assertThat(list.addBefore("blah", 'e', "e"), CoreMatchers.nullValue());
-        Assert.assertThat(list.getSize(), CoreMatchers.equalTo(2));
-
-        Assert.assertThat(list.addAfter("yada", 'e', "e"), CoreMatchers.nullValue());
-        Assert.assertThat(list.getSize(), CoreMatchers.equalTo(2));
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/1eb22180/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestCloseableHttpClient.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestCloseableHttpClient.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestCloseableHttpClient.java
index 7d8299c..99687d6 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestCloseableHttpClient.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestCloseableHttpClient.java
@@ -35,7 +35,7 @@ import org.apache.hc.core5.http.ClassicHttpResponse;
 import org.apache.hc.core5.http.HttpEntity;
 import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.http.HttpResponse;
-import org.apache.hc.core5.http.io.ResponseHandler;
+import org.apache.hc.core5.http.io.HttpClientResponseHandler;
 import org.apache.hc.core5.http.protocol.HttpContext;
 import org.junit.Assert;
 import org.junit.Before;
@@ -119,7 +119,7 @@ public class TestCloseableHttpClient {
         Mockito.when(client.doExecute(
                 new HttpHost("somehost", 444, "https"), httpget, null)).thenReturn(response);
 
-        final ResponseHandler<HttpResponse> handler = Mockito.mock(ResponseHandler.class);
+        final HttpClientResponseHandler<HttpResponse> handler = Mockito.mock(HttpClientResponseHandler.class);
 
         client.execute(httpget, handler);
 
@@ -139,7 +139,7 @@ public class TestCloseableHttpClient {
         Mockito.when(client.doExecute(
                 new HttpHost("somehost", 444, "https"), httpget, null)).thenReturn(response);
 
-        final ResponseHandler<HttpResponse> handler = Mockito.mock(ResponseHandler.class);
+        final HttpClientResponseHandler<HttpResponse> handler = Mockito.mock(HttpClientResponseHandler.class);
 
         Mockito.when(handler.handleResponse(response)).thenThrow(new IOException());
 
@@ -163,7 +163,7 @@ public class TestCloseableHttpClient {
         Mockito.when(client.doExecute(
                 new HttpHost("somehost", 444, "https"), httpget, null)).thenReturn(response);
 
-        final ResponseHandler<HttpResponse> handler = Mockito.mock(ResponseHandler.class);
+        final HttpClientResponseHandler<HttpResponse> handler = Mockito.mock(HttpClientResponseHandler.class);
 
         Mockito.when(handler.handleResponse(response)).thenThrow(new RuntimeException());
 


Mime
View raw message