You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2012/09/28 11:23:13 UTC

svn commit: r1391373 - /camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java

Author: davsclaus
Date: Fri Sep 28 09:23:12 2012
New Revision: 1391373

URL: http://svn.apache.org/viewvc?rev=1391373&view=rev
Log:
CAMEL-5561: ExecutorServiceManagement should shutdown after services

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

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=1391373&r1=1391372&r2=1391373&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Fri Sep 28 09:23:12 2012
@@ -894,7 +894,10 @@ public class DefaultCamelContext extends
     }
 
     public void addService(Object object) throws Exception {
+        doAddService(object, true);
+    }
 
+    private void doAddService(Object object, boolean closeOnShutdown) throws Exception {
         // inject CamelContext
         if (object instanceof CamelContextAware) {
             CamelContextAware aware = (CamelContextAware) object;
@@ -922,7 +925,7 @@ public class DefaultCamelContext extends
             // do not add endpoints as they have their own list
             if (singleton && !(service instanceof Endpoint)) {
                 // only add to list of services to close if its not already there
-                if (!hasService(service)) {
+                if (closeOnShutdown && !hasService(service)) {
                     servicesToClose.add(service);
                 }
             }
@@ -1544,7 +1547,8 @@ public class DefaultCamelContext extends
         // and we needed to create endpoints up-front as it may be accessed before this context is started
         endpoints = new EndpointRegistry(this, endpoints);
         addService(endpoints);
-        addService(executorServiceManager);
+        // special for executorServiceManager as want to stop it manually
+        doAddService(executorServiceManager, false);
         addService(producerServicePool);
         addService(inflightRepository);
         addService(shutdownStrategy);
@@ -1644,7 +1648,8 @@ public class DefaultCamelContext extends
             shutdownServices(notifier);
         }
 
-        // shutdown management as the last one
+        // shutdown executor service and management as the last one
+        shutdownServices(executorServiceManager);
         shutdownServices(managementStrategy);
         shutdownServices(lifecycleStrategies);
         // do not clear lifecycleStrategies as we can start Camel again and get the route back as before