[ 
https://issues.apache.org/jira/browse/CAMEL-22529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18034460#comment-18034460
 ] 

Claus Ibsen commented on CAMEL-22529:
-------------------------------------

Ah okay so this is actually how the Java DSL builds up that route configuration 
which ends up as one combined
{code:java}
.onException(IllegalArgumentException.class, Exception.class).handled(true)
.log("NOK: ${exception}")
.log("OK: ${exception}");
  {code}
 
So the problem is that it should be seperated, which is how you would do in in 
a normal route builder

> camel-core: onException doesn't work as expected
> ------------------------------------------------
>
>                 Key: CAMEL-22529
>                 URL: https://issues.apache.org/jira/browse/CAMEL-22529
>             Project: Camel
>          Issue Type: Bug
>          Components: came-core
>    Affects Versions: 4.10.7
>            Reporter: Mike Kobler
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 4.10.8, 4.14.3, 4.17.0
>
>
> When using a RouteConfigurationBuilder with multiple onException blocks, 
> Apache Camel incorrectly matches the thrown exception to the wrong handler.
> {code:java}
> public class Xyz extends RouteConfigurationBuilder {
>   @Override
>   public void configuration() throws Exception {
>     routeConfiguration()
>       .onException(HttpOperationFailedException.class)
>         .log(LoggingLevel.ERROR, "Test HttpOperationFailedException: 
> ${exception}")
>       .onException(Exception.class)
>         .log(LoggingLevel.ERROR, "Test Exception: ${exception}")
>       ;
>   }
> }{code}
> This example outputs "Test HttpOperationFailedException: java.lang.Exception" 
> when java.lang.Exception is thrown. Expected result would be "Test Exception: 
> java.lang.Exception"
> Am I doing something wrong or is this a bug?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to