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/04/21 10:52:00 UTC

svn commit: r1328618 - in /camel/branches/camel-2.8.x: ./ camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java camel-core/src/test/java/org/apache/camel/issues/NotifyBuilderOnFailureShutdownCamelIssueTest.java

Author: davsclaus
Date: Sat Apr 21 08:52:00 2012
New Revision: 1328618

URL: http://svn.apache.org/viewvc?rev=1328618&view=rev
Log:
CAMEL-5200: Fixed potential dead-lock with getRoutes on CamelContext, during shutdown of Camel.

Added:
    camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/issues/NotifyBuilderOnFailureShutdownCamelIssueTest.java
      - copied unchanged from r1328615, camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/issues/NotifyBuilderOnFailureShutdownCamelIssueTest.java
Modified:
    camel/branches/camel-2.8.x/   (props changed)
    camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java

Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1328614
  Merged /camel/branches/camel-2.9.x:r1328615

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

Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=1328618&r1=1328617&r2=1328618&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original)
+++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Sat Apr 21 08:52:00 2012
@@ -139,7 +139,7 @@ public class DefaultCamelContext extends
     private final AtomicInteger endpointKeyCounter = new AtomicInteger();
     private final List<EndpointStrategy> endpointStrategies = new ArrayList<EndpointStrategy>();
     private final Map<String, Component> components = new HashMap<String, Component>();
-    private Set<Route> routes;
+    private final Set<Route> routes = new LinkedHashSet<Route>();
     private final List<Service> servicesToClose = new ArrayList<Service>();
     private final Set<StartupListener> startupListeners = new LinkedHashSet<StartupListener>();
     private TypeConverter typeConverter;
@@ -562,13 +562,8 @@ public class DefaultCamelContext extends
         return routeStartupOrder;
     }
 
-    public synchronized List<Route> getRoutes() {
-        if (routes == null) {
-            routes = new LinkedHashSet<Route>();
-        }
-
-        // lets return a copy of the collection as objects are removed later
-        // when services are stopped
+    public List<Route> getRoutes() {
+        // lets return a copy of the collection as objects are removed later when services are stopped
         return new ArrayList<Route>(routes);
     }
 
@@ -587,19 +582,11 @@ public class DefaultCamelContext extends
     }
 
     synchronized void removeRouteCollection(Collection<Route> routes) {
-        if (this.routes != null) {
-            this.routes.removeAll(routes);
-        }
+        this.routes.removeAll(routes);
     }
 
     synchronized void addRouteCollection(Collection<Route> routes) throws Exception {
-        if (this.routes == null) {
-            this.routes = new LinkedHashSet<Route>();
-        }
-
-        if (routes != null) {
-            this.routes.addAll(routes);
-        }
+        this.routes.addAll(routes);
     }
 
     public void addRoutes(RoutesBuilder builder) throws Exception {