PoolingClientConnectionManager does not use ClientConnectionOperator#createConnection() method to create new connections

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1442566 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2013-02-05 12:39:21 +00:00
parent 5cd571a159
commit 3627984c9d
2 changed files with 11 additions and 3 deletions

View File

@ -31,6 +31,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.http.conn.ClientConnectionOperator;
import org.apache.http.conn.OperatedClientConnection; import org.apache.http.conn.OperatedClientConnection;
import org.apache.http.conn.routing.HttpRoute; import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.pool.AbstractConnPool; import org.apache.http.pool.AbstractConnPool;
@ -51,9 +52,10 @@ class HttpConnPool extends AbstractConnPool<HttpRoute, OperatedClientConnection,
private final TimeUnit tunit; private final TimeUnit tunit;
public HttpConnPool(final Log log, public HttpConnPool(final Log log,
final ClientConnectionOperator connOperator,
final int defaultMaxPerRoute, final int maxTotal, final int defaultMaxPerRoute, final int maxTotal,
final long timeToLive, final TimeUnit tunit) { final long timeToLive, final TimeUnit tunit) {
super(new InternalConnFactory(), defaultMaxPerRoute, maxTotal); super(new InternalConnFactory(connOperator), defaultMaxPerRoute, maxTotal);
this.log = log; this.log = log;
this.timeToLive = timeToLive; this.timeToLive = timeToLive;
this.tunit = tunit; this.tunit = tunit;
@ -67,8 +69,14 @@ class HttpConnPool extends AbstractConnPool<HttpRoute, OperatedClientConnection,
static class InternalConnFactory implements ConnFactory<HttpRoute, OperatedClientConnection> { static class InternalConnFactory implements ConnFactory<HttpRoute, OperatedClientConnection> {
private final ClientConnectionOperator connOperator;
InternalConnFactory(final ClientConnectionOperator connOperator) {
this.connOperator = connOperator;
}
public OperatedClientConnection create(final HttpRoute route) throws IOException { public OperatedClientConnection create(final HttpRoute route) throws IOException {
return new DefaultClientConnection(); return connOperator.createConnection();
} }
} }

View File

@ -111,7 +111,7 @@ public class PoolingClientConnectionManager implements ClientConnectionManager,
this.schemeRegistry = schemeRegistry; this.schemeRegistry = schemeRegistry;
this.dnsResolver = dnsResolver; this.dnsResolver = dnsResolver;
this.operator = createConnectionOperator(schemeRegistry); this.operator = createConnectionOperator(schemeRegistry);
this.pool = new HttpConnPool(this.log, 2, 20, timeToLive, tunit); this.pool = new HttpConnPool(this.log, this.operator, 2, 20, timeToLive, tunit);
} }
@Override @Override