diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java b/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java index b0a5394d6..19c8c360a 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java @@ -34,6 +34,7 @@ import java.util.Queue; import java.util.LinkedList; import java.util.Map; import java.util.Set; +import java.util.Stack; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.TimeUnit; @@ -82,7 +83,7 @@ public class ConnPoolByRoute extends AbstractConnPool { //TODO: remove dependenc protected final Set leasedConnections; /** The list of free connections */ - protected final Queue freeConnections; + protected final Stack freeConnections; /** The list of WaitingThreads waiting for a connection */ protected final Queue waitingThreads; @@ -162,8 +163,8 @@ public class ConnPoolByRoute extends AbstractConnPool { //TODO: remove dependenc * * @return a queue */ - protected Queue createFreeConnQueue() { - return new LinkedList(); + protected Stack createFreeConnQueue() { + return new Stack(); } /** @@ -462,7 +463,7 @@ public class ConnPoolByRoute extends AbstractConnPool { //TODO: remove dependenc } rospl.freeEntry(entry); entry.updateExpiry(validDuration, timeUnit); - freeConnections.add(entry); + freeConnections.push(entry); } else { rospl.dropEntry(); numConnections--; @@ -611,7 +612,7 @@ public class ConnPoolByRoute extends AbstractConnPool { //TODO: remove dependenc poolLock.lock(); try { - BasicPoolEntry entry = freeConnections.remove(); + BasicPoolEntry entry = freeConnections.pop(); if (entry != null) { deleteEntry(entry);