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 2013/08/22 09:14:00 UTC
[2/2] git commit: CAMEL-6378: Add validation that onException must be
configured on route scope level when using Java DSL.
CAMEL-6378: Add validation that onException must be configured on route scope level when using Java DSL.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9f527e43
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9f527e43
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9f527e43
Branch: refs/heads/master
Commit: 9f527e431e4afe0f48a7da3dced6d2d4a778bc92
Parents: 6f489f1
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Aug 22 08:07:05 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Aug 22 09:13:49 2013 +0200
----------------------------------------------------------------------
.../apache/camel/model/ProcessorDefinition.java | 30 ++++++++++++++------
1 file changed, 22 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/9f527e43/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
index e2f06bf..9eaea62 100644
--- a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
@@ -2357,10 +2357,17 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @return the exception builder to configure
*/
public OnExceptionDefinition onException(Class<? extends Throwable> exceptionType) {
- OnExceptionDefinition answer = new OnExceptionDefinition(exceptionType);
- answer.setRouteScoped(true);
- addOutput(answer);
- return answer;
+ // onException can only be added on the route-level and not nested in splitter/policy etc
+ // Camel 3.0 will fix this where we will have a RouteScopeDefinition where route scoped
+ // configuration must take place, and not from this generic ProcessorDefinition
+ if (this.getClass().isAssignableFrom(RouteDefinition.class)) {
+ OnExceptionDefinition answer = new OnExceptionDefinition(exceptionType);
+ answer.setRouteScoped(true);
+ addOutput(answer);
+ return answer;
+ } else {
+ throw new IllegalArgumentException("onException can only be added directly to the route. Try moving this onException to the top of the route: " + this);
+ }
}
/**
@@ -2371,10 +2378,17 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @return the exception builder to configure
*/
public OnExceptionDefinition onException(Class<? extends Throwable>... exceptions) {
- OnExceptionDefinition answer = new OnExceptionDefinition(Arrays.asList(exceptions));
- answer.setRouteScoped(true);
- addOutput(answer);
- return answer;
+ // onException can only be added on the route-level and not nested in splitter/policy etc
+ // Camel 3.0 will fix this where we will have a RouteScopeDefinition where route scoped
+ // configuration must take place, and not from this generic ProcessorDefinition
+ if (this.getClass().isAssignableFrom(RouteDefinition.class)) {
+ OnExceptionDefinition answer = new OnExceptionDefinition(Arrays.asList(exceptions));
+ answer.setRouteScoped(true);
+ addOutput(answer);
+ return answer;
+ } else {
+ throw new IllegalArgumentException("onException can only be added directly to the route. Try moving this onException to the top of the route: " + this);
+ }
}
/**