Author: davsclaus
Date: Tue Feb 28 07:48:21 2012
New Revision: 1294502

URL: http://svn.apache.org/viewvc?rev=1294502&view=rev
Log:
CAMEL-5042: Shutting down a thread pool should remove the pool from the 
internal reference list

Modified:
    
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceManager.java

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceManager.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceManager.java?rev=1294502&r1=1294501&r2=1294502&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceManager.java
 (original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceManager.java
 Tue Feb 28 07:48:21 2012
@@ -264,6 +264,10 @@ public class DefaultExecutorServiceManag
 
     @Override
     public List<Runnable> shutdownNow(ExecutorService executorService) {
+        return doShutdownNow(executorService, true);
+    }
+
+    private List<Runnable> doShutdownNow(ExecutorService executorService, 
boolean remove) {
         ObjectHelper.notNull(executorService, "executorService");
 
         List<Runnable> answer = null;
@@ -281,7 +285,9 @@ public class DefaultExecutorServiceManag
         }
 
         // remove reference as its shutdown
-        executorServices.remove(executorService);
+        if (remove) {
+            executorServices.remove(executorService);
+        }
 
         return answer;
     }
@@ -310,11 +316,12 @@ public class DefaultExecutorServiceManag
 
     @Override
     protected void doShutdown() throws Exception {
-        // shutdown all executor services
+        // shutdown all executor services by looping
         for (ExecutorService executorService : executorServices) {
             // only log if something goes wrong as we want to shutdown them all
             try {
-                shutdownNow(executorService);
+                // must not remove during looping, as we clear the list 
afterwards
+                doShutdownNow(executorService, false);
             } catch (Throwable e) {
                 LOG.warn("Error occurred during shutdown of ExecutorService: "
                         + executorService + ". This exception will be 
ignored.", e);


Reply via email to