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/11/28 18:15:41 UTC

svn commit: r1414827 - in /camel/branches/camel-2.9.x: ./ camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java

Author: davsclaus
Date: Wed Nov 28 17:15:40 2012
New Revision: 1414827

URL: http://svn.apache.org/viewvc?rev=1414827&view=rev
Log:
CAMEL-5830 fix the NPE when the shutdown the route which is not started rightly.

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

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1414740
  Merged /camel/branches/camel-2.10.x:r1414823

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/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=1414827&r1=1414826&r2=1414827&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original)
+++ camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Wed Nov 28 17:15:40 2012
@@ -1807,21 +1807,28 @@ public class DefaultCamelContext extends
         routeService.setRemovingRoutes(removingRoutes);
         stopRouteService(routeService);
     }
+    
+    protected void logRouteState(Route route, String state) {
+        if (log.isInfoEnabled()) {
+            if (route.getConsumer() != null) {
+                log.info("Route: {} {}, was consuming from: {}", route.getId(), state, route.getConsumer().getEndpoint());
+            } else {
+                log.info("Route: {} {}.", route.getId(), state);
+            }
+        }
+    }
+    
     protected synchronized void stopRouteService(RouteService routeService) throws Exception {
         routeService.stop();
         for (Route route : routeService.getRoutes()) {
-            if (log.isInfoEnabled()) {
-                log.info("Route: " + route.getId() + " stopped, was consuming from: " + route.getConsumer().getEndpoint());
-            }
+            logRouteState(route, "stoped");
         }
     }
 
     protected synchronized void shutdownRouteService(RouteService routeService) throws Exception {
         routeService.shutdown();
         for (Route route : routeService.getRoutes()) {
-            if (log.isInfoEnabled()) {
-                log.info("Route: " + route.getId() + " shutdown and removed, was consuming from: " + route.getConsumer().getEndpoint());
-            }
+            logRouteState(route, "shutdown and removed");
         }
     }
 
@@ -1829,9 +1836,7 @@ public class DefaultCamelContext extends
         routeService.setRemovingRoutes(false);
         routeService.suspend();
         for (Route route : routeService.getRoutes()) {
-            if (log.isInfoEnabled()) {
-                log.info("Route: " + route.getId() + " suspended, was consuming from: " + route.getConsumer().getEndpoint());
-            }
+            logRouteState(route, "suspended");
         }
     }