Author: davsclaus
Date: Tue Feb 28 07:53:45 2012
New Revision: 1294507

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

Modified:
    camel/branches/camel-2.9.x/   (props changed)
    
camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceManager.java

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Feb 28 07:53:45 2012
@@ -1 +1 @@
-/camel/trunk:1243046,1243057,1243234,1244518,1244644,1244859,1244861,1244864,1244870,1244872,1245021,1291555,1291727,1291848,1291864,1292114,1292384,1292725,1292760,1292767,1293079,1293268,1293288,1293330,1293590,1293828,1293852,1293855,1294130,1294482
+/camel/trunk:1243046,1243057,1243234,1244518,1244644,1244859,1244861,1244864,1244870,1244872,1245021,1291555,1291727,1291848,1291864,1292114,1292384,1292725,1292760,1292767,1293079,1293268,1293288,1293330,1293590,1293828,1293852,1293855,1294130,1294482,1294502

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: 
camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceManager.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceManager.java?rev=1294507&r1=1294506&r2=1294507&view=diff
==============================================================================
--- 
camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceManager.java
 (original)
+++ 
camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceManager.java
 Tue Feb 28 07:53:45 2012
@@ -259,6 +259,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");
 
         if (executorService.isShutdown()) {
@@ -270,7 +274,9 @@ public class DefaultExecutorServiceManag
         LOG.trace("ShutdownNow ExecutorService: {} complete.", 
executorService);
 
         // remove reference as its shutdown
-        executorServices.remove(executorService);
+        if (remove) {
+            executorServices.remove(executorService);
+        }
 
         return answer;
     }
@@ -299,11 +305,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