ttyy1112 edited a comment on pull request #5890: URL: https://github.com/apache/camel/pull/5890#issuecomment-889760939
Well, to make my change work, I have to make some change of the failed test case. And I think we should take a further discussion why I want to change the code like this. As the endChoice() javadoc described: If you want to end the entire choice block, then use end() instead. The purpose of endChoice() is to return control back to the choice() DSL, so you can add subsequent when and otherwise to the choice. Now, consider the to DSL below. DSL-TWO looks more regular and well-organized, but it does not work. DSL-ONE: from("direct:start") .choice() .when(header("foo").isGreaterThan(1)) .choice() .when(header("foo").isGreaterThan(5)).to("mock:big") .otherwise().to("mock:med") .endChoice() .otherwise().to("mock:low") .end(); DSL-TWO: from("direct:start") .choice() .when(header("foo").isGreaterThan(1)) .choice() .when(header("foo").isGreaterThan(5)).to("mock:big").endChoice() .otherwise().to("mock:med").endChoice() .end() .endChoice() .otherwise().to("mock:low").endChoice() .end(); To make nest choice work, we must remember the most outer choice should end by end() method, while inner choice must end with endChoice() method and the most inner choice must not include enChoice() in both when and otherwise clause. It's not end, if you have another EIP DSL in your most inner when or otherwise clause, endChoice() is needed. There are so many rules you should remember! Sometimes, I want to generate the Java-DSL dynamically and I don't know how many nest choices it will be, and also have no idea whether there is another EIP DSL in the when clause or not. So In this case, I hope the choice clause below would always work. (eg. DSL-TWO) .choice() .when().log().endChoice() .when().log().endChoice() .otherwise().log().endChoice() .end() Though a little redundancy, I think it will simple in use. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org