"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.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.

ConnPoolByRoute.java  (httpcomponents-client-4.5.6-src):ConnPoolByRoute.java  (httpcomponents-client-4.5.7-src)
skipping to change at line 296 skipping to change at line 296
try { try {
aborter.abort(); aborter.abort();
} finally { } finally {
poolLock.unlock(); poolLock.unlock();
} }
} }
@Override @Override
public BasicPoolEntry getPoolEntry( public BasicPoolEntry getPoolEntry(
final long timeout, final long timeout,
final TimeUnit tunit) final TimeUnit timeUnit)
throws InterruptedException, ConnectionPoolTimeoutExcept ion { throws InterruptedException, ConnectionPoolTimeoutExcept ion {
return getEntryBlocking(route, state, timeout, tunit, aborter); return getEntryBlocking(route, state, timeout, timeUnit, aborter );
} }
}; };
} }
/** /**
* Obtains a pool entry with a connection within the given timeout. * Obtains a pool entry with a connection within the given timeout.
* If a {@link WaitingThread} is used to block, {@link WaitingThreadAborter# setWaitingThread(WaitingThread)} * If a {@link WaitingThread} is used to block, {@link WaitingThreadAborter# setWaitingThread(WaitingThread)}
* must be called before blocking, to allow the thread to be interrupted. * must be called before blocking, to allow the thread to be interrupted.
* *
* @param route the route for which to get the connection * @param route the route for which to get the connection
* @param timeout the timeout, 0 or negative for no timeout * @param timeout the timeout, 0 or negative for no timeout
* @param tunit the unit for the {@code timeout}, * @param timeUnit the unit for the {@code timeout},
* may be {@code null} only if there is no timeout * may be {@code null} only if there is no timeout
* @param aborter an object which can abort a {@link WaitingThread}. * @param aborter an object which can abort a {@link WaitingThread}.
* *
* @return pool entry holding a connection for the route * @return pool entry holding a connection for the route
* *
* @throws ConnectionPoolTimeoutException * @throws ConnectionPoolTimeoutException
* if the timeout expired * if the timeout expired
* @throws InterruptedException * @throws InterruptedException
* if the calling thread was interrupted * if the calling thread was interrupted
*/ */
protected BasicPoolEntry getEntryBlocking( protected BasicPoolEntry getEntryBlocking(
final HttpRoute route, final Object state, final HttpRoute route, final Object state,
final long timeout, final TimeUnit tunit, final long timeout, final TimeUnit timeUnit,
final WaitingThreadAborter aborter) final WaitingThreadAborter aborter)
throws ConnectionPoolTimeoutException, InterruptedException { throws ConnectionPoolTimeoutException, InterruptedException {
Date deadline = null; Date deadline = null;
if (timeout > 0) { if (timeout > 0) {
deadline = new Date deadline = new Date
(System.currentTimeMillis() + tunit.toMillis(timeout)); (System.currentTimeMillis() + timeUnit.toMillis(timeout));
} }
BasicPoolEntry entry = null; BasicPoolEntry entry = null;
poolLock.lock(); poolLock.lock();
try { try {
RouteSpecificPool rospl = getRoutePool(route, true); RouteSpecificPool rospl = getRoutePool(route, true);
WaitingThread waitingThread = null; WaitingThread waitingThread = null;
while (entry == null) { while (entry == null) {
skipping to change at line 707 skipping to change at line 707
} finally { } finally {
poolLock.unlock(); poolLock.unlock();
} }
} }
/** /**
* Closes idle connections. * Closes idle connections.
* *
* @param idletime the time the connections should have been idle * @param idletime the time the connections should have been idle
* in order to be closed now * in order to be closed now
* @param tunit the unit for the {@code idletime} * @param timeUnit the unit for the {@code idletime}
*/ */
@Override @Override
public void closeIdleConnections(final long idletime, final TimeUnit tunit) public void closeIdleConnections(final long idletime, final TimeUnit timeUni
{ t) {
Args.notNull(tunit, "Time unit"); Args.notNull(timeUnit, "Time unit");
final long t = idletime > 0 ? idletime : 0; final long t = idletime > 0 ? idletime : 0;
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Closing connections idle longer than " + t + " " + tunit ); log.debug("Closing connections idle longer than " + t + " " + timeU nit);
} }
// the latest time for which connections will be closed // the latest time for which connections will be closed
final long deadline = System.currentTimeMillis() - tunit.toMillis(t); final long deadline = System.currentTimeMillis() - timeUnit.toMillis(t);
poolLock.lock(); poolLock.lock();
try { try {
final Iterator<BasicPoolEntry> iter = freeConnections.iterator(); final Iterator<BasicPoolEntry> iter = freeConnections.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
final BasicPoolEntry entry = iter.next(); final BasicPoolEntry entry = iter.next();
if (entry.getUpdated() <= deadline) { if (entry.getUpdated() <= deadline) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Closing connection last used @ " + new Date(e ntry.getUpdated())); log.debug("Closing connection last used @ " + new Date(e ntry.getUpdated()));
} }
iter.remove(); iter.remove();
 End of changes. 9 change blocks. 
11 lines changed or deleted 11 lines changed or added

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