applied shutdownAll() part of HTTPCLIENT-625
git-svn-id: https://svn.apache.org/repos/asf/jakarta/httpcomponents/httpclient/trunk@508782 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
12d50dda30
commit
486dd14981
|
@ -405,12 +405,20 @@ public class ThreadSafeClientConnManager
|
||||||
synchronized (REFERENCE_TO_CONNECTION_SOURCE) {
|
synchronized (REFERENCE_TO_CONNECTION_SOURCE) {
|
||||||
// shutdown all connection managers
|
// shutdown all connection managers
|
||||||
synchronized (ALL_CONNECTION_MANAGERS) {
|
synchronized (ALL_CONNECTION_MANAGERS) {
|
||||||
Iterator connIter = ALL_CONNECTION_MANAGERS.keySet().iterator();
|
// Don't use an iterator here. Iterators on WeakHashMap can
|
||||||
while (connIter.hasNext()) {
|
// get ConcurrentModificationException on garbage collection.
|
||||||
ThreadSafeClientConnManager connManager =
|
MultiThreadedHttpConnectionManager[]
|
||||||
(ThreadSafeClientConnManager) connIter.next();
|
connManagers = (MultiThreadedHttpConnectionManager[])
|
||||||
connIter.remove();
|
ALL_CONNECTION_MANAGERS.keySet().toArray(
|
||||||
connManager.shutdown();
|
new MultiThreadedHttpConnectionManager
|
||||||
|
[ALL_CONNECTION_MANAGERS.size()]
|
||||||
|
);
|
||||||
|
|
||||||
|
// The map may shrink after size() is called, or some entry
|
||||||
|
// may get GCed while the array is built, so expect null.
|
||||||
|
for (int i=0; i<connManagers.length; i++) {
|
||||||
|
if (connManagers[i] != null)
|
||||||
|
connManagers[i].shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue