camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r893136 - /camel/trunk/camel-core/src/main/java/org/apache/camel/processor/UnitOfWorkProcessor.java
Date Tue, 22 Dec 2009 11:10:14 GMT
Author: davsclaus
Date: Tue Dec 22 11:10:12 2009
New Revision: 893136

URL: http://svn.apache.org/viewvc?rev=893136&view=rev
Log:
CAMEL-2310: UnitOfWork is not always done in finally to ensure even when Error is throw we
will done also

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/UnitOfWorkProcessor.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/UnitOfWorkProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/UnitOfWorkProcessor.java?rev=893136&r1=893135&r2=893136&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/UnitOfWorkProcessor.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/UnitOfWorkProcessor.java
Tue Dec 22 11:10:12 2009
@@ -20,6 +20,8 @@
 import org.apache.camel.Processor;
 import org.apache.camel.impl.DefaultUnitOfWork;
 import org.apache.camel.spi.RouteContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import static org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException;
 
@@ -29,6 +31,7 @@
  */
 public final class UnitOfWorkProcessor extends DelegateProcessor {
 
+    private static final transient Log LOG = LogFactory.getLog(UnitOfWorkProcessor.class);
     private final RouteContext routeContext;
 
     public UnitOfWorkProcessor(Processor processor) {
@@ -63,16 +66,10 @@
                 processor.process(exchange);
             } catch (Exception e) {
                 exchange.setException(e);
+            } finally {
+                // must always done unit of work
+                done(uow, exchange);
             }
-
-            // unit of work is done
-            exchange.getUnitOfWork().done(exchange);
-            try {
-                uow.stop();
-            } catch (Exception e) {
-                throw wrapRuntimeCamelException(e);
-            }
-            exchange.setUnitOfWork(null);
         } else {
             // There was an existing UoW, so we should just pass through..
             // so that the guy the initiated the UoW can terminate it.
@@ -80,4 +77,16 @@
         }
     }
 
+    private void done(DefaultUnitOfWork uow, Exchange exchange) {
+        // unit of work is done
+        exchange.getUnitOfWork().done(exchange);
+        try {
+            uow.stop();
+        } catch (Exception e) {
+            LOG.warn("Exception occurred during stopping UnitOfWork for Exchange: " + exchange
+                + ". This exception will be ignored.");
+        }
+        exchange.setUnitOfWork(null);
+    }
+
 }



Mime
View raw message