Upgraded HttpCore to version 4.2-alpha2
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1174627 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
eab98043c4
commit
9ee4a41aa3
|
@ -31,10 +31,10 @@ 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.HttpConnection;
|
|
||||||
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;
|
||||||
|
import org.apache.http.pool.ConnFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
|
@ -50,33 +50,24 @@ class HttpConnPool extends AbstractConnPool<HttpRoute, OperatedClientConnection,
|
||||||
public HttpConnPool(final Log log,
|
public HttpConnPool(final Log log,
|
||||||
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(defaultMaxPerRoute, maxTotal);
|
super(new InternalConnFactory(), defaultMaxPerRoute, maxTotal);
|
||||||
this.log = log;
|
this.log = log;
|
||||||
this.timeToLive = timeToLive;
|
this.timeToLive = timeToLive;
|
||||||
this.tunit = tunit;
|
this.tunit = tunit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected OperatedClientConnection createConnection(final HttpRoute route) throws IOException {
|
|
||||||
return new DefaultClientConnection();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HttpPoolEntry createEntry(final HttpRoute route, final OperatedClientConnection conn) {
|
protected HttpPoolEntry createEntry(final HttpRoute route, final OperatedClientConnection conn) {
|
||||||
String id = Long.toString(COUNTER.getAndIncrement());
|
String id = Long.toString(COUNTER.getAndIncrement());
|
||||||
return new HttpPoolEntry(this.log, id, route, conn, this.timeToLive, this.tunit);
|
return new HttpPoolEntry(this.log, id, route, conn, this.timeToLive, this.tunit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
static class InternalConnFactory implements ConnFactory<HttpRoute, OperatedClientConnection> {
|
||||||
protected void closeEntry(final HttpPoolEntry entry) {
|
|
||||||
HttpConnection conn = entry.getConnection();
|
public OperatedClientConnection create(final HttpRoute route) throws IOException {
|
||||||
try {
|
return new DefaultClientConnection();
|
||||||
conn.shutdown();
|
|
||||||
} catch (IOException ex) {
|
|
||||||
if (this.log.isDebugEnabled()) {
|
|
||||||
this.log.debug("I/O error shutting down connection", ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.http.impl.conn;
|
package org.apache.http.impl.conn;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@ -75,4 +76,20 @@ class HttpPoolEntry extends PoolEntry<HttpRoute, OperatedClientConnection> {
|
||||||
return this.tracker.toRoute();
|
return this.tracker.toRoute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isClosed() {
|
||||||
|
OperatedClientConnection conn = getConnection();
|
||||||
|
return !conn.isOpen();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
OperatedClientConnection conn = getConnection();
|
||||||
|
try {
|
||||||
|
conn.close();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
this.log.debug("I/O error closing connection", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -310,14 +310,26 @@ public class PoolingClientConnectionManager implements ClientConnectionManager,
|
||||||
this.pool.closeExpired();
|
this.pool.closeExpired();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMaxTotal() {
|
||||||
|
return this.pool.getMaxTotal();
|
||||||
|
}
|
||||||
|
|
||||||
public void setMaxTotal(int max) {
|
public void setMaxTotal(int max) {
|
||||||
this.pool.setMaxTotal(max);
|
this.pool.setMaxTotal(max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getDefaultMaxPerRoute() {
|
||||||
|
return this.pool.getDefaultMaxPerRoute();
|
||||||
|
}
|
||||||
|
|
||||||
public void setDefaultMaxPerRoute(int max) {
|
public void setDefaultMaxPerRoute(int max) {
|
||||||
this.pool.setDefaultMaxPerRoute(max);
|
this.pool.setDefaultMaxPerRoute(max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMaxPerRoute(final HttpRoute route) {
|
||||||
|
return this.pool.getMaxPerRoute(route);
|
||||||
|
}
|
||||||
|
|
||||||
public void setMaxPerRoute(final HttpRoute route, int max) {
|
public void setMaxPerRoute(final HttpRoute route, int max) {
|
||||||
this.pool.setMaxPerRoute(route, max);
|
this.pool.setMaxPerRoute(route, max);
|
||||||
}
|
}
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -67,7 +67,7 @@
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<httpcore.version>4.2-alpha1</httpcore.version>
|
<httpcore.version>4.2-alpha2</httpcore.version>
|
||||||
<commons-logging.version>1.1.1</commons-logging.version>
|
<commons-logging.version>1.1.1</commons-logging.version>
|
||||||
<commons-codec.version>1.4</commons-codec.version>
|
<commons-codec.version>1.4</commons-codec.version>
|
||||||
<ehcache.version>2.2.0</ehcache.version>
|
<ehcache.version>2.2.0</ehcache.version>
|
||||||
|
|
Loading…
Reference in New Issue