svn commit: r1169611 - in /camel/branches/camel-2.8.x: ./ camel-core/src/main/java/org/apache/camel/model/ camel-core/src/main/java/org/apache/camel/processor/ components/camel-spring/src/test/java/org/apache/camel/spring/issues/ components/camel-sprin...

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1169611 - in /camel/branches/camel-2.8.x: ./ camel-core/src/main/java/org/apache/camel/model/ camel-core/src/main/java/org/apache/camel/processor/ components/camel-spring/src/test/java/org/apache/camel/spring/issues/ components/camel-sprin...

davsclaus-2
Author: davsclaus
Date: Mon Sep 12 06:06:31 2011
New Revision: 1169611

URL: http://svn.apache.org/viewvc?rev=1169611&view=rev
Log:
Merged revisions 1169610 via svnmerge from
https://svn.apache.org/repos/asf/camel/trunk


Added:
    camel/branches/camel-2.8.x/components/camel-spring/src/test/java/org/apache/camel/spring/issues/RedeliveryErrorHandlerTwoXmlFilesIssueTest.java
      - copied unchanged from r1169610, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/issues/RedeliveryErrorHandlerTwoXmlFilesIssueTest.java
    camel/branches/camel-2.8.x/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/RedeliveryErrorHandlerTwoXmlFilesIssueTest-1.xml
      - copied unchanged from r1169610, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/RedeliveryErrorHandlerTwoXmlFilesIssueTest-1.xml
    camel/branches/camel-2.8.x/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/RedeliveryErrorHandlerTwoXmlFilesIssueTest-2.xml
      - copied unchanged from r1169610, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/RedeliveryErrorHandlerTwoXmlFilesIssueTest-2.xml
Modified:
    camel/branches/camel-2.8.x/   (props changed)
    camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
    camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java

Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Sep 12 06:06:31 2011
@@ -1 +1 @@
-/camel/trunk:1148706,1148710,1149570,1150651,1151000,1151054,1151087,1151362,1152170,1152755,1153620,1153812,1153829,1154684,1155230,1156108,1156260,1156277,1156479,1156524,1157348,1157749,1157798,1157831,1157878,1158153,1159171,1159174,1159326,1159457,1159460,1159606,1159682-1159683,1159867,1160547,1160637,1161010,1161082,1161524,1162309,1162395,1163231,1163420,1164557,1164633,1164973-1165000,1165152,1165157,1165658,1165971,1165987,1167098,1167131,1167448,1167487,1167555
+/camel/trunk:1148706,1148710,1149570,1150651,1151000,1151054,1151087,1151362,1152170,1152755,1153620,1153812,1153829,1154684,1155230,1156108,1156260,1156277,1156479,1156524,1157348,1157749,1157798,1157831,1157878,1158153,1159171,1159174,1159326,1159457,1159460,1159606,1159682-1159683,1159867,1160547,1160637,1161010,1161082,1161524,1162309,1162395,1163231,1163420,1164557,1164633,1164973-1165000,1165152,1165157,1165658,1165971,1165987,1167098,1167131,1167448,1167487,1167555,1169610

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/model/OnExceptionDefinition.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java?rev=1169611&r1=1169610&r2=1169611&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java (original)
+++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java Mon Sep 12 06:06:31 2011
@@ -124,24 +124,25 @@ public class OnExceptionDefinition exten
      * Allows an exception handler to create a new redelivery policy for this exception type
      *
      * @param context      the camel context
-     * @param parentPolicy the current redelivery policy
+     * @param parentPolicy the current redelivery policy, is newer <tt>null</tt>
      * @return a newly created redelivery policy, or return the original policy if no customization is required
      *         for this exception handler.
      */
     public RedeliveryPolicy createRedeliveryPolicy(CamelContext context, RedeliveryPolicy parentPolicy) {
         if (redeliveryPolicyRef != null) {
-            parentPolicy = CamelContextHelper.mandatoryLookup(context, redeliveryPolicyRef, RedeliveryPolicy.class);
-        }
-
-        if (redeliveryPolicy != null) {
+            return CamelContextHelper.mandatoryLookup(context, redeliveryPolicyRef, RedeliveryPolicy.class);
+        } else if (redeliveryPolicy != null) {
             return redeliveryPolicy.createRedeliveryPolicy(context, parentPolicy);
-        } else if (errorHandler != null) {
-            // lets create a new error handler that has no retries
+        } else if (!outputs.isEmpty() && parentPolicy.getMaximumRedeliveries() > 0) {
+            // if we have outputs, then do not inherit parent maximumRedeliveries
+            // as you would have to explicit configure maximumRedeliveries on this onException to use it
+            // this is the behavior Camel has always had
             RedeliveryPolicy answer = parentPolicy.copy();
             answer.setMaximumRedeliveries(0);
             return answer;
+        } else {
+            return parentPolicy;
         }
-        return parentPolicy;
     }
 
     public void addRoutes(RouteContext routeContext, Collection<Route> routes) throws Exception {

Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java?rev=1169611&r1=1169610&r2=1169611&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java (original)
+++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java Mon Sep 12 06:06:31 2011
@@ -548,6 +548,9 @@ public abstract class RedeliveryErrorHan
     }
 
     protected void prepareExchangeForRedelivery(Exchange exchange, RedeliveryData data) {
+        if (!redeliveryEnabled) {
+            throw new IllegalStateException("Redelivery is not enabled on " + this + ". Make sure you have configured the error handler properly.");
+        }
         // there must be a defensive copy of the exchange
         ObjectHelper.notNull(data.original, "Defensive copy of Exchange is null", this);
 
@@ -950,21 +953,19 @@ public abstract class RedeliveryErrorHan
             // walk them to see if any of them have a maximum redeliveries > 0 or retry until set
             for (OnExceptionDefinition def : exceptionPolicies.values()) {
 
-                if (def.getRedeliveryPolicy() != null) {
-                    String ref = def.getRedeliveryPolicyRef();
-                    if (ref != null) {
-                        // lookup in registry if ref provided
-                        RedeliveryPolicy policy = CamelContextHelper.mandatoryLookup(camelContext, ref, RedeliveryPolicy.class);
-                        if (policy.getMaximumRedeliveries() != 0) {
-                            // must check for != 0 as (-1 means redeliver forever)
-                            return true;
-                        }
-                    } else {
-                        Integer max = CamelContextHelper.parseInteger(camelContext, def.getRedeliveryPolicy().getMaximumRedeliveries());
-                        if (max != null && max != 0) {
-                            // must check for != 0 as (-1 means redeliver forever)
-                            return true;
-                        }
+                String ref = def.getRedeliveryPolicyRef();
+                if (ref != null) {
+                    // lookup in registry if ref provided
+                    RedeliveryPolicy policy = CamelContextHelper.mandatoryLookup(camelContext, ref, RedeliveryPolicy.class);
+                    if (policy.getMaximumRedeliveries() != 0) {
+                        // must check for != 0 as (-1 means redeliver forever)
+                        return true;
+                    }
+                } else if (def.getRedeliveryPolicy() != null) {
+                    Integer max = CamelContextHelper.parseInteger(camelContext, def.getRedeliveryPolicy().getMaximumRedeliveries());
+                    if (max != null && max != 0) {
+                        // must check for != 0 as (-1 means redeliver forever)
+                        return true;
                     }
                 }