diff --git a/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java b/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java index e6286e8c8..20b7af241 100644 --- a/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java +++ b/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java @@ -448,7 +448,10 @@ protected BasicPoolEntry getFreeEntry(RouteSpecificPool rospl, Object state) { LOG.debug("Closing expired free connection" + " [" + rospl.getRoute() + "][" + state + "]"); closeConnection(entry.getConnection()); - rospl.deleteEntry(entry); + // We use dropEntry instead of deleteEntry because the entry + // is no longer "free" (we just allocated it), and deleteEntry + // can only be used to delete free entries. + rospl.dropEntry(); numConnections--; } else { issuedConnections.add(entry.getWeakRef()); diff --git a/module-client/src/test/java/org/apache/http/conn/TestConnectionReuse.java b/module-client/src/test/java/org/apache/http/conn/TestConnectionReuse.java index 88b38ef25..b57f57104 100644 --- a/module-client/src/test/java/org/apache/http/conn/TestConnectionReuse.java +++ b/module-client/src/test/java/org/apache/http/conn/TestConnectionReuse.java @@ -311,9 +311,9 @@ public void testKeepAliveHeaderRespected() throws Exception { HttpProtocolParams.setUserAgent(params, "TestAgent/1.1"); HttpProtocolParams.setUseExpectContinue(params, false); HttpConnectionParams.setStaleCheckingEnabled(params, false); - ConnManagerParams.setMaxTotalConnections(params, 5); + ConnManagerParams.setMaxTotalConnections(params, 1); ConnManagerParams.setMaxConnectionsPerRoute(params, - new ConnPerRouteBean(5)); + new ConnPerRouteBean(1)); SchemeRegistry supportedSchemes = new SchemeRegistry(); SocketFactory sf = PlainSocketFactory.getSocketFactory(); @@ -360,7 +360,7 @@ public void testKeepAliveHeaderRespected() throws Exception { mgr.shutdown(); - } + } private static class WorkerThread extends Thread {