Index: C:/Documents and Settings/Michael/My Documents/HttpClient/HttpClient-3.0/src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java =================================================================== --- C:/Documents and Settings/Michael/My Documents/HttpClient/HttpClient-3.0/src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java (revision 430219) +++ C:/Documents and Settings/Michael/My Documents/HttpClient/HttpClient-3.0/src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java (working copy) @@ -798,7 +798,7 @@ HostConnectionPool hostPool = getHostPool(hostConfiguration); if (hostPool.freeConnections.size() > 0) { - connection = (HttpConnectionWithReference) hostPool.freeConnections.removeFirst(); + connection = (HttpConnectionWithReference) hostPool.freeConnections.removeLast(); freeConnections.remove(connection); // store a reference to this connection so that it can be cleaned up // in the event it is not correctly released Index: C:/Documents and Settings/Michael/My Documents/HttpClient/HttpClient-3.0/src/java/org/apache/commons/httpclient/util/IdleConnectionTimeoutThread.java =================================================================== --- C:/Documents and Settings/Michael/My Documents/HttpClient/HttpClient-3.0/src/java/org/apache/commons/httpclient/util/IdleConnectionTimeoutThread.java (revision 430219) +++ C:/Documents and Settings/Michael/My Documents/HttpClient/HttpClient-3.0/src/java/org/apache/commons/httpclient/util/IdleConnectionTimeoutThread.java (working copy) @@ -83,6 +83,15 @@ } /** + * Handles calling {@link HttpConnectionManager#closeIdleConnections(long) closeIdleConnections()} + * and doing any other cleanup work on the given connection mangaer. + * @param connectionManager The connection manager to close idle connections for + */ + protected void handleCloseIdleConnections(HttpConnectionManager connectionManager) { + connectionManager.closeIdleConnections(connectionTimeout); + } + + /** * Closes idle connections. */ public synchronized void run() { @@ -91,7 +100,7 @@ while (iter.hasNext()) { HttpConnectionManager connectionManager = (HttpConnectionManager) iter.next(); - connectionManager.closeIdleConnections(connectionTimeout); + handleCloseIdleConnections(connectionManager); } try {