Author: davsclaus
Date: Sat Jan  5 07:40:08 2013
New Revision: 1429220

URL: http://svn.apache.org/viewvc?rev=1429220&view=rev
Log:
CAMEL-5925: Fixed potential NPE in RouteContextProcessor. Thanks to Taariq 
Levack for the patch.

Added:
    
camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/RouteContextProcessorTest.java
      - copied unchanged from r1429219, 
camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/processor/RouteContextProcessorTest.java
Modified:
    camel/branches/camel-2.9.x/   (props changed)
    
camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/processor/RouteContextProcessor.java

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1429218
  Merged /camel/branches/camel-2.10.x:r1429219

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/processor/RouteContextProcessor.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/processor/RouteContextProcessor.java?rev=1429220&r1=1429219&r2=1429220&view=diff
==============================================================================
--- 
camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/processor/RouteContextProcessor.java
 (original)
+++ 
camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/processor/RouteContextProcessor.java
 Sat Jan  5 07:40:08 2013
@@ -27,7 +27,7 @@ import org.apache.camel.spi.UnitOfWork;
  * This ensures that the {@link Exchange} have details under which route its 
being currently processed.
  */
 public class RouteContextProcessor extends DelegateAsyncProcessor {
-    
+
     private final RouteContext routeContext;
 
     public RouteContextProcessor(RouteContext routeContext, Processor 
processor) {
@@ -38,17 +38,17 @@ public class RouteContextProcessor exten
     @Override
     protected boolean processNext(final Exchange exchange, final AsyncCallback 
callback) {
         // push the current route context
-        if (exchange.getUnitOfWork() != null) {
-            exchange.getUnitOfWork().pushRouteContext(routeContext);
+        final UnitOfWork unitOfWork = exchange.getUnitOfWork();
+        if (unitOfWork != null) {
+            unitOfWork.pushRouteContext(routeContext);
         }
 
         boolean sync = processor.process(exchange, new AsyncCallback() {
             public void done(boolean doneSync) {
                 try {
-                    UnitOfWork uow = exchange.getUnitOfWork();
                     // pop the route context we just used
-                    if (uow != null) {
-                        uow.popRouteContext();
+                    if (unitOfWork != null) {
+                        unitOfWork.popRouteContext();
                     }
                 } catch (Exception e) {
                     exchange.setException(e);


Reply via email to