BasicHttpClientConnectionManager.java (httpcomponents-client-4.5.5-src) | : | BasicHttpClientConnectionManager.java (httpcomponents-client-4.5.6-src) | ||
---|---|---|---|---|
skipping to change at line 160 | skipping to change at line 160 | |||
protected void finalize() throws Throwable { | protected void finalize() throws Throwable { | |||
try { | try { | |||
shutdown(); | shutdown(); | |||
} finally { // Make sure we call overridden method even if shutdown barf s | } finally { // Make sure we call overridden method even if shutdown barf s | |||
super.finalize(); | super.finalize(); | |||
} | } | |||
} | } | |||
@Override | @Override | |||
public void close() { | public void close() { | |||
shutdown(); | if (this.isShutdown.compareAndSet(false, true)) { | |||
closeConnection(); | ||||
} | ||||
} | } | |||
HttpRoute getRoute() { | HttpRoute getRoute() { | |||
return route; | return route; | |||
} | } | |||
Object getState() { | Object getState() { | |||
return state; | return state; | |||
} | } | |||
skipping to change at line 209 | skipping to change at line 211 | |||
@Override | @Override | |||
public HttpClientConnection get(final long timeout, final TimeUnit t unit) { | public HttpClientConnection get(final long timeout, final TimeUnit t unit) { | |||
return BasicHttpClientConnectionManager.this.getConnection( | return BasicHttpClientConnectionManager.this.getConnection( | |||
route, state); | route, state); | |||
} | } | |||
}; | }; | |||
} | } | |||
private void closeConnection() { | private synchronized void closeConnection() { | |||
if (this.conn != null) { | if (this.conn != null) { | |||
this.log.debug("Closing connection"); | this.log.debug("Closing connection"); | |||
try { | try { | |||
this.conn.close(); | this.conn.close(); | |||
} catch (final IOException iox) { | } catch (final IOException iox) { | |||
if (this.log.isDebugEnabled()) { | if (this.log.isDebugEnabled()) { | |||
this.log.debug("I/O exception closing connection", iox); | this.log.debug("I/O exception closing connection", iox); | |||
} | } | |||
} | } | |||
this.conn = null; | this.conn = null; | |||
} | } | |||
} | } | |||
private void shutdownConnection() { | ||||
if (this.conn != null) { | ||||
this.log.debug("Shutting down connection"); | ||||
try { | ||||
this.conn.shutdown(); | ||||
} catch (final IOException iox) { | ||||
if (this.log.isDebugEnabled()) { | ||||
this.log.debug("I/O exception shutting down connection", iox | ||||
); | ||||
} | ||||
} | ||||
this.conn = null; | ||||
} | ||||
} | ||||
private void checkExpiry() { | private void checkExpiry() { | |||
if (this.conn != null && System.currentTimeMillis() >= this.expiry) { | if (this.conn != null && System.currentTimeMillis() >= this.expiry) { | |||
if (this.log.isDebugEnabled()) { | if (this.log.isDebugEnabled()) { | |||
this.log.debug("Connection expired @ " + new Date(this.expiry)); | this.log.debug("Connection expired @ " + new Date(this.expiry)); | |||
} | } | |||
closeConnection(); | closeConnection(); | |||
} | } | |||
} | } | |||
synchronized HttpClientConnection getConnection(final HttpRoute route, final Object state) { | synchronized HttpClientConnection getConnection(final HttpRoute route, final Object state) { | |||
skipping to change at line 376 | skipping to change at line 364 | |||
time = 0; | time = 0; | |||
} | } | |||
final long deadline = System.currentTimeMillis() - time; | final long deadline = System.currentTimeMillis() - time; | |||
if (this.updated <= deadline) { | if (this.updated <= deadline) { | |||
closeConnection(); | closeConnection(); | |||
} | } | |||
} | } | |||
} | } | |||
@Override | @Override | |||
public synchronized void shutdown() { | public void shutdown() { | |||
if (this.isShutdown.compareAndSet(false, true)) { | close(); | |||
shutdownConnection(); | ||||
} | ||||
} | } | |||
} | } | |||
End of changes. 4 change blocks. | ||||
21 lines changed or deleted | 6 lines changed or added |