"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "httpclient/src/main/java-deprecated/org/apache/http/impl/conn/PoolingClientConnectionManager.java" between
httpcomponents-client-4.5.6-src.tar.gz and httpcomponents-client-4.5.7-src.tar.gz

About: HttpComponents is an Apache project responsible for creating and maintaining a toolset of low level Java components focused on HTTP and associated protocols. Java sources.

PoolingClientConnectionManager.java  (httpcomponents-client-4.5.6-src):PoolingClientConnectionManager.java  (httpcomponents-client-4.5.7-src)
skipping to change at line 101 skipping to change at line 101
public PoolingClientConnectionManager(final SchemeRegistry schreg,final DnsR esolver dnsResolver) { public PoolingClientConnectionManager(final SchemeRegistry schreg,final DnsR esolver dnsResolver) {
this(schreg, -1, TimeUnit.MILLISECONDS,dnsResolver); this(schreg, -1, TimeUnit.MILLISECONDS,dnsResolver);
} }
public PoolingClientConnectionManager() { public PoolingClientConnectionManager() {
this(SchemeRegistryFactory.createDefault()); this(SchemeRegistryFactory.createDefault());
} }
public PoolingClientConnectionManager( public PoolingClientConnectionManager(
final SchemeRegistry schemeRegistry, final SchemeRegistry schemeRegistry,
final long timeToLive, final TimeUnit tunit) { final long timeToLive, final TimeUnit timeUnit) {
this(schemeRegistry, timeToLive, tunit, new SystemDefaultDnsResolver()); this(schemeRegistry, timeToLive, timeUnit, new SystemDefaultDnsResolver(
));
} }
public PoolingClientConnectionManager(final SchemeRegistry schemeRegistry, public PoolingClientConnectionManager(final SchemeRegistry schemeRegistry,
final long timeToLive, final TimeUnit tunit, final long timeToLive, final TimeUnit timeUnit,
final DnsResolver dnsResolver) { final DnsResolver dnsResolver) {
super(); super();
Args.notNull(schemeRegistry, "Scheme registry"); Args.notNull(schemeRegistry, "Scheme registry");
Args.notNull(dnsResolver, "DNS resolver"); Args.notNull(dnsResolver, "DNS resolver");
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, this.operator, 2, 20, timeToLive, tunit); this.pool = new HttpConnPool(this.log, this.operator, 2, 20, timeToLive, timeUnit);
} }
@Override @Override
protected void finalize() throws Throwable { protected void finalize() throws Throwable {
try { try {
shutdown(); shutdown();
} finally { } finally {
super.finalize(); super.finalize();
} }
} }
skipping to change at line 199 skipping to change at line 199
return new ClientConnectionRequest() { return new ClientConnectionRequest() {
@Override @Override
public void abortRequest() { public void abortRequest() {
future.cancel(true); future.cancel(true);
} }
@Override @Override
public ManagedClientConnection getConnection( public ManagedClientConnection getConnection(
final long timeout, final long timeout,
final TimeUnit tunit) throws InterruptedException, Connectio final TimeUnit timeUnit) throws InterruptedException, Connec
nPoolTimeoutException { tionPoolTimeoutException {
return leaseConnection(future, timeout, tunit); return leaseConnection(future, timeout, timeUnit);
} }
}; };
} }
ManagedClientConnection leaseConnection( ManagedClientConnection leaseConnection(
final Future<HttpPoolEntry> future, final Future<HttpPoolEntry> future,
final long timeout, final long timeout,
final TimeUnit tunit) throws InterruptedException, ConnectionPoolTim eoutException { final TimeUnit timeUnit) throws InterruptedException, ConnectionPool TimeoutException {
final HttpPoolEntry entry; final HttpPoolEntry entry;
try { try {
entry = future.get(timeout, tunit); entry = future.get(timeout, timeUnit);
if (entry == null || future.isCancelled()) { if (entry == null || future.isCancelled()) {
throw new InterruptedException(); throw new InterruptedException();
} }
Asserts.check(entry.getConnection() != null, "Pool entry with no con nection"); Asserts.check(entry.getConnection() != null, "Pool entry with no con nection");
if (this.log.isDebugEnabled()) { if (this.log.isDebugEnabled()) {
this.log.debug("Connection leased: " + format(entry) + formatSta ts(entry.getRoute())); this.log.debug("Connection leased: " + format(entry) + formatSta ts(entry.getRoute()));
} }
return new ManagedClientConnectionImpl(this, this.operator, entry); return new ManagedClientConnectionImpl(this, this.operator, entry);
} catch (final ExecutionException ex) { } catch (final ExecutionException ex) {
Throwable cause = ex.getCause(); Throwable cause = ex.getCause();
skipping to change at line 237 skipping to change at line 237
this.log.error("Unexpected exception leasing connection from pool", cause); this.log.error("Unexpected exception leasing connection from pool", cause);
// Should never happen // Should never happen
throw new InterruptedException(); throw new InterruptedException();
} catch (final TimeoutException ex) { } catch (final TimeoutException ex) {
throw new ConnectionPoolTimeoutException("Timeout waiting for connec tion from pool"); throw new ConnectionPoolTimeoutException("Timeout waiting for connec tion from pool");
} }
} }
@Override @Override
public void releaseConnection( public void releaseConnection(
final ManagedClientConnection conn, final long keepalive, final Time Unit tunit) { final ManagedClientConnection conn, final long keepalive, final Time Unit timeUnit) {
Args.check(conn instanceof ManagedClientConnectionImpl, "Connection clas s mismatch, " + Args.check(conn instanceof ManagedClientConnectionImpl, "Connection clas s mismatch, " +
"connection not obtained from this manager"); "connection not obtained from this manager");
final ManagedClientConnectionImpl managedConn = (ManagedClientConnection Impl) conn; final ManagedClientConnectionImpl managedConn = (ManagedClientConnection Impl) conn;
Asserts.check(managedConn.getManager() == this, "Connection not obtained from this manager"); Asserts.check(managedConn.getManager() == this, "Connection not obtained from this manager");
synchronized (managedConn) { synchronized (managedConn) {
final HttpPoolEntry entry = managedConn.detach(); final HttpPoolEntry entry = managedConn.detach();
if (entry == null) { if (entry == null) {
return; return;
} }
skipping to change at line 260 skipping to change at line 260
try { try {
managedConn.shutdown(); managedConn.shutdown();
} catch (final IOException iox) { } catch (final IOException iox) {
if (this.log.isDebugEnabled()) { if (this.log.isDebugEnabled()) {
this.log.debug("I/O exception shutting down released connection", iox); this.log.debug("I/O exception shutting down released connection", iox);
} }
} }
} }
// Only reusable connections can be kept alive // Only reusable connections can be kept alive
if (managedConn.isMarkedReusable()) { if (managedConn.isMarkedReusable()) {
entry.updateExpiry(keepalive, tunit != null ? tunit : TimeUn it.MILLISECONDS); entry.updateExpiry(keepalive, timeUnit != null ? timeUnit : TimeUnit.MILLISECONDS);
if (this.log.isDebugEnabled()) { if (this.log.isDebugEnabled()) {
final String s; final String s;
if (keepalive > 0) { if (keepalive > 0) {
s = "for " + keepalive + " " + tunit; s = "for " + keepalive + " " + timeUnit;
} else { } else {
s = "indefinitely"; s = "indefinitely";
} }
this.log.debug("Connection " + format(entry) + " can be kept alive " + s); this.log.debug("Connection " + format(entry) + " can be kept alive " + s);
} }
} }
} finally { } finally {
this.pool.release(entry, managedConn.isMarkedReusable()); this.pool.release(entry, managedConn.isMarkedReusable());
} }
if (this.log.isDebugEnabled()) { if (this.log.isDebugEnabled()) {
skipping to change at line 292 skipping to change at line 292
this.log.debug("Connection manager is shutting down"); this.log.debug("Connection manager is shutting down");
try { try {
this.pool.shutdown(); this.pool.shutdown();
} catch (final IOException ex) { } catch (final IOException ex) {
this.log.debug("I/O exception shutting down connection manager", ex) ; this.log.debug("I/O exception shutting down connection manager", ex) ;
} }
this.log.debug("Connection manager shut down"); this.log.debug("Connection manager shut down");
} }
@Override @Override
public void closeIdleConnections(final long idleTimeout, final TimeUnit tuni t) { public void closeIdleConnections(final long idleTimeout, final TimeUnit time Unit) {
if (this.log.isDebugEnabled()) { if (this.log.isDebugEnabled()) {
this.log.debug("Closing connections idle longer than " + idleTimeout + " " + tunit); this.log.debug("Closing connections idle longer than " + idleTimeout + " " + timeUnit);
} }
this.pool.closeIdle(idleTimeout, tunit); this.pool.closeIdle(idleTimeout, timeUnit);
} }
@Override @Override
public void closeExpiredConnections() { public void closeExpiredConnections() {
this.log.debug("Closing expired connections"); this.log.debug("Closing expired connections");
this.pool.closeExpired(); this.pool.closeExpired();
} }
@Override @Override
public int getMaxTotal() { public int getMaxTotal() {
 End of changes. 12 change blocks. 
15 lines changed or deleted 16 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)