Author: davsclaus
Date: Wed Apr 11 07:16:17 2012
New Revision: 1324599

URL: http://svn.apache.org/viewvc?rev=1324599&view=rev
Log:
CAMEL-5162: OnException handled/continued predicates should only be evaluate 
once per exception, instead of twice.

Added:
    
camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionContinuePredicateTest.java
      - copied unchanged from r1324598, 
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionContinuePredicateTest.java
    
camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionContinueTwoPredicateTest.java
      - copied unchanged from r1324598, 
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionContinueTwoPredicateTest.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/RedeliveryErrorHandler.java

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1324598

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/RedeliveryErrorHandler.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java?rev=1324599&r1=1324598&r2=1324599&view=diff
==============================================================================
--- 
camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
 (original)
+++ 
camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
 Wed Apr 11 07:16:17 2012
@@ -712,9 +712,12 @@ public abstract class RedeliveryErrorHan
         // clear exception as we let the failure processor handle it
         exchange.setException(null);
 
-        boolean handled = false;
+        final boolean shouldHandle = shouldHandled(exchange, data);
+        final boolean shouldContinue = shouldContinue(exchange, data);
         // regard both handled or continued as being handled
-        if (shouldHandled(exchange, data) || shouldContinue(exchange, data)) {
+        boolean handled = false;
+
+        if (shouldHandle || shouldContinue) {
             // its handled then remove traces of redelivery attempted
             exchange.getIn().removeHeader(Exchange.REDELIVERED);
             exchange.getIn().removeHeader(Exchange.REDELIVERY_COUNTER);
@@ -759,7 +762,7 @@ public abstract class RedeliveryErrorHan
                 public void done(boolean sync) {
                     log.trace("Failure processor done: {} processing Exchange: 
{}", processor, exchange);
                     try {
-                        prepareExchangeAfterFailure(exchange, data);
+                        prepareExchangeAfterFailure(exchange, data, 
shouldHandle, shouldContinue);
                         // fire event as we had a failure processor to handle 
it, which there is a event for
                         boolean deadLetterChannel = processor == 
data.deadLetterProcessor && data.deadLetterProcessor != null;
                         
EventHelper.notifyExchangeFailureHandled(exchange.getContext(), exchange, 
processor, deadLetterChannel);
@@ -773,7 +776,7 @@ public abstract class RedeliveryErrorHan
         } else {
             try {
                 // no processor but we need to prepare after failure as well
-                prepareExchangeAfterFailure(exchange, data);
+                prepareExchangeAfterFailure(exchange, data, shouldHandle, 
shouldContinue);
             } finally {
                 // callback we are done
                 callback.done(data.sync);
@@ -793,7 +796,8 @@ public abstract class RedeliveryErrorHan
         return sync;
     }
 
-    protected void prepareExchangeAfterFailure(final Exchange exchange, final 
RedeliveryData data) {
+    protected void prepareExchangeAfterFailure(final Exchange exchange, final 
RedeliveryData data,
+                                               final boolean shouldHandle, 
final boolean shouldContinue) {
         // we could not process the exchange so we let the failure processor 
handled it
         ExchangeHelper.setFailureHandled(exchange);
 
@@ -813,10 +817,10 @@ public abstract class RedeliveryErrorHan
             return;
         }
 
-        if (shouldHandled(exchange, data)) {
+        if (shouldHandle) {
             log.trace("This exchange is handled so its marked as not failed: 
{}", exchange);
             exchange.setProperty(Exchange.ERRORHANDLER_HANDLED, Boolean.TRUE);
-        } else if (shouldContinue(exchange, data)) {
+        } else if (shouldContinue) {
             log.trace("This exchange is continued: {}", exchange);
             // okay we want to continue then prepare the exchange for that as 
well
             prepareExchangeForContinue(exchange, data);


Reply via email to