camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1150651 - /camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java
Date Mon, 25 Jul 2011 12:02:26 GMT
Author: ningjiang
Date: Mon Jul 25 12:02:26 2011
New Revision: 1150651

URL: http://svn.apache.org/viewvc?rev=1150651&view=rev
Log:
CAMEL-4264 The routeContext stack of DefaultUnitOfWork should be thread safe

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

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java?rev=1150651&r1=1150650&r2=1150651&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java Mon
Jul 25 12:02:26 2011
@@ -261,21 +261,27 @@ public class DefaultUnitOfWork implement
     }
 
     public RouteContext getRouteContext() {
-        if (routeContextStack.isEmpty()) {
-            return null;
+        synchronized (routeContextStack) {
+            if (routeContextStack.isEmpty()) {
+                return null;
+            }
+            return routeContextStack.peek();
         }
-        return routeContextStack.peek();
     }
 
     public void pushRouteContext(RouteContext routeContext) {
-        routeContextStack.add(routeContext);
+        synchronized (routeContext) {
+            routeContextStack.add(routeContext);
+        }
     }
 
     public RouteContext popRouteContext() {
-        if (routeContextStack.isEmpty()) {
-            return null;
+        synchronized (routeContextStack) {
+            if (routeContextStack.isEmpty()) {
+                return null;
+            }
+            return routeContextStack.pop();
         }
-        return routeContextStack.pop();
     }
 
     public AsyncCallback beforeProcess(Processor processor, Exchange exchange, AsyncCallback
callback) {



Mime
View raw message