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

RobinBezuijen commented on CAMEL-6447:
--------------------------------------

It looks like this issue was introduced in 2.10.4

The problem is that adding the end() before the endChoice() will only work for 
2.10.4 and above because it will break when using 2.10.3 with the following 
exception:

{code}
org.springframework.beans.factory.BeanCreationException: Error creating bean 
with name 'test-route': Invocation of init method failed; nested exception is 
java.lang.ClassCastException: org.apache.camel.model.RouteDefinition cannot be 
cast to org.apache.camel.model.ChoiceDefinition
        at 
org.apache.camel.model.ProcessorDefinition.endChoice(ProcessorDefinition.java:1256)
{code}



                
> endChoice() has no effect in nested choice definition
> -----------------------------------------------------
>
>                 Key: CAMEL-6447
>                 URL: https://issues.apache.org/jira/browse/CAMEL-6447
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.11.0
>            Reporter: Christian Tytgat
>
> I just upgraded from 2.10.4 to 2.11.0 and noticed that nested choice 
> definitions started acting strangely. For example:
> {code:java}
>             .choice()
>                 .when(header(Exchange.EXCEPTION_CAUGHT).isNotNull())
>                     // 1
>                     
> .setBody(exceptionMessage().append(SystemUtils.LINE_SEPARATOR).append(exceptionStackTrace()))
>                     .choice()
>                         .when(header(HEADER_CONTROLLER_ID).isNotNull())
>                             // 1a
>                             .setHeader(Exchange.FILE_NAME, 
> simple(AUDIT_CONTROLLER_FAILED_FILENAME + ".error.log"))
>                             .to(ENDPOINT_AUDIT_DIR)
>                         .otherwise()
>                             // 1b
>                             .setHeader(Exchange.FILE_NAME, 
> simple(AUDIT_FAILED_FILENAME + ".error.log"))
>                             .to(ENDPOINT_AUDIT_DIR)
>                             // INSERTING .end() here solves the issue
>                         .endChoice()
>                     .log(LoggingLevel.WARN, "DLQ written: 
> ${in.header.CamelExceptionCaught}"
>                 .otherwise()
>                     // 2
>                     .log(LoggingLevel.WARN, "DLQ written" + 
> MESSAGE_LOG_FORMAT)
>                 .end()
> {code}
> I have a test that is supposed to go through 1 and 1a. However it now passes 
> through 1 and 2!
> It looks like the endChoice() in 1b has no effect and the otherwise() in 2 is 
> executed instead of 1b. Inserting and end() statement as shown seems to solve 
> the issue, but it looks suspicious.
> It's probably a regression introduced by the fix for CAMEL-5953, but I'm not 
> 100% sure. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to