You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2011/02/24 06:23:09 UTC
svn commit: r1074046 - in /camel/trunk/camel-core/src:
main/java/org/apache/camel/model/RouteDefinitionHelper.java
test/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategyUsingWhenTest.java
Author: davsclaus
Date: Thu Feb 24 05:23:08 2011
New Revision: 1074046
URL: http://svn.apache.org/viewvc?rev=1074046&view=rev
Log:
CAMEL-3711: Fixed onException with same type is preserved in same order when route is built
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategyUsingWhenTest.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java?rev=1074046&r1=1074045&r2=1074046&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java Thu Feb 24 05:23:08 2011
@@ -19,7 +19,6 @@ package org.apache.camel.model;
import java.util.ArrayList;
import java.util.List;
-import org.apache.camel.impl.InterceptSendToEndpoint;
import org.apache.camel.util.EndpointHelper;
/**
@@ -144,12 +143,26 @@ public final class RouteDefinitionHelper
if (output instanceof OnExceptionDefinition) {
// on exceptions must be added at top, so the route flow is correct as
// on exceptions should be the first outputs
- upper.add(0, output);
+
+ // find the index to add the on exception, it should be in the top
+ // but it should add itself after any existing onException
+ int index = 0;
+ for (int i = 0; i < upper.size(); i++) {
+ ProcessorDefinition up = upper.get(i);
+ if (!(up instanceof OnExceptionDefinition)) {
+ index = i;
+ break;
+ } else {
+ index++;
+ }
+ }
+ upper.add(index, output);
}
}
}
- private static void initInterceptors(RouteDefinition route, List<ProcessorDefinition> abstracts, List<ProcessorDefinition> upper,
+ private static void initInterceptors(RouteDefinition route,
+ List<ProcessorDefinition> abstracts, List<ProcessorDefinition> upper,
List<InterceptDefinition> intercepts,
List<InterceptFromDefinition> interceptFromDefinitions,
List<InterceptSendToEndpointDefinition> interceptSendToEndpointDefinitions) {
@@ -178,9 +191,9 @@ public final class RouteDefinitionHelper
}
private static void doInitInterceptors(RouteDefinition route, List<ProcessorDefinition> upper,
- List<InterceptDefinition> intercepts,
- List<InterceptFromDefinition> interceptFromDefinitions,
- List<InterceptSendToEndpointDefinition> interceptSendToEndpointDefinitions) {
+ List<InterceptDefinition> intercepts,
+ List<InterceptFromDefinition> interceptFromDefinitions,
+ List<InterceptSendToEndpointDefinition> interceptSendToEndpointDefinitions) {
// configure intercept
if (intercepts != null && !intercepts.isEmpty()) {
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategyUsingWhenTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategyUsingWhenTest.java?rev=1074046&r1=1074045&r2=1074046&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategyUsingWhenTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategyUsingWhenTest.java Thu Feb 24 05:23:08 2011
@@ -79,7 +79,7 @@ public class DefaultExceptionPolicyStrat
// here we define onException to catch MyUserException as a kind
// of fallback when the above did not match.
- // Noitce: The order how we have defined these onException is
+ // Notice: The order how we have defined these onException is
// important as Camel will resolve in the same order as they
// have been defined
onException(MyUserException.class)