mirror of
https://github.com/apache/httpcomponents-client.git
synced 2025-02-16 23:16:33 +00:00
HTTPCLIENT-677: no Thread.interrupt() for shutdown
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@607421 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7a2a85f25e
commit
540984183f
@ -1,8 +1,7 @@
|
||||
Changes since 4.0 Alpha 2
|
||||
-------------------
|
||||
|
||||
* [HTTPCLIENT-677] Thread safe client connection manager no longer uses
|
||||
Thread.interrupt() when a connection becomes available.
|
||||
* [HTTPCLIENT-677] Connection manager no longer uses Thread.interrupt()
|
||||
Contributed by Roland Weber <rolandw at apache.org>
|
||||
|
||||
* [HTTPCLIENT-716] Allow application-defined routes.
|
||||
|
@ -239,27 +239,20 @@ public BasicPoolEntry getEntry(HttpRoute route, long timeout,
|
||||
|
||||
rospl.queueThread(waitingThread);
|
||||
waitingThreads.add(waitingThread);
|
||||
success = waitingThread.await(timeToWait); //@@@, TimeUnit.MILLISECONDS);
|
||||
//@@@ The 'success' flag is somewhat different from the
|
||||
//@@@ previous technique using interrupts. If the CM is
|
||||
//@@@ shutting down, we now get an InterruptedException
|
||||
//@@@ and have no check for that special case. What we
|
||||
//@@@ want to do is to let the exception fly through.
|
||||
//@@@ Actually, we may want to have a special exception
|
||||
//@@@ for the shutdown case, but that is goldplating.
|
||||
|
||||
success = waitingThread.await(timeToWait); //@@@, TimeUnit.MILLISECONDS); or deadline
|
||||
} finally {
|
||||
if (!success) {
|
||||
// Either we timed out, experienced a
|
||||
// "spurious wakeup", or were interrupted by an
|
||||
// external thread. Regardless we need to
|
||||
// "spurious wakeup", or were interrupted by
|
||||
// an external thread. Regardless, we need to
|
||||
// cleanup for ourselves in the wait queue.
|
||||
rospl.removeThread(waitingThread);
|
||||
waitingThreads.remove(waitingThread);
|
||||
}
|
||||
// In case of 'success', we were woken up by the
|
||||
// connection pool and should now have a connection
|
||||
// waiting for us. Continue in the loop and get it.
|
||||
// waiting for us, or else we're shutting down.
|
||||
// Just continue in the loop, both cases are checked.
|
||||
|
||||
if (useTimeout) {
|
||||
endWait = System.currentTimeMillis();
|
||||
@ -571,12 +564,12 @@ public void shutdown() {
|
||||
closeConnection(entry.getConnection());
|
||||
}
|
||||
|
||||
// interrupt all waiting threads
|
||||
// wake up all waiting threads
|
||||
Iterator<WaitingThread> iwth = waitingThreads.iterator();
|
||||
while (iwth.hasNext()) {
|
||||
WaitingThread waiter = iwth.next();
|
||||
iwth.remove();
|
||||
waiter.getThread().interrupt();
|
||||
waiter.wakeup();
|
||||
}
|
||||
|
||||
routeToPool.clear();
|
||||
|
Loading…
x
Reference in New Issue
Block a user