Index: src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java =================================================================== --- src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java (revision 560349) +++ src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java (working copy) @@ -781,7 +781,11 @@ public synchronized void handleLostConnection(HostConfiguration config) { HostConnectionPool hostPool = getHostPool(config); hostPool.numConnections--; - if (hostPool.numConnections == 0) mapHosts.remove(config); + if ((hostPool.numConnections == 0) && + hostPool.waitingThreads.isEmpty()) { + + mapHosts.remove(config); + } numConnections--; notifyWaitingThread(config); @@ -888,7 +892,11 @@ hostPool.freeConnections.remove(connection); hostPool.numConnections--; numConnections--; - if (hostPool.numConnections == 0) mapHosts.remove(connectionConfiguration); + if ((hostPool.numConnections == 0) && + hostPool.waitingThreads.isEmpty()) { + + mapHosts.remove(connectionConfiguration); + } // remove the connection from the timeout handler idleConnectionHandler.remove(connection);