I've noticed the weaveById() creates a duplicated endpoint if there's a
"choice" in my camel route.
I'm running camel 2.12.3 with java 1.7.0_55.

I've built a test case to demonstrate this issue:
git clone https://github.com/joaocenoura/sandbox.git
mvn clean package -f sandbox/camel-weaving/pom.xml

There are two junit test with the following routes:
GoodRouteTest

from("direct:start").id("start")
  .to("mock:checkpoint").id("checkpoint")
  .to("mock:end").id("end");


BadRouteTest

from("direct:start").id("start")
  .setHeader("hello", constant("world"))
  .choice()
  .when(header("hello").isEqualTo("world"))
  .to("mock:checkpoint").id("checkpoint")
  .endChoice()
  .otherwise()
  // this shouldn't be called
  .to("mock:deadend").id("deadend")
  .end()
  .to("mock:end").id("end");


The BadRouteTest just introduces the choice/when/otherwise.
The problem is when I add a AdviseWithRouteBuilder with
'weaveById("checkpoint").before().to("mock:checkpoint.before");' it creates
2 endpoints instead of one. I've noticed the logs of junit confirms that.

Excerpt of GoodRouteTest logs:
23:44:45,644 INFO             -            - AdviceWithTasks
 - AdviceWith (checkpoint) : [To[mock:checkpoint]] --> before [pipeline ->
[[To[mock:checkpoint.before]]]]
23:44:45,644 INFO             -            - AdviceWithTasks
 - AdviceWith (checkpoint) : [To[mock:checkpoint]] --> after [pipeline ->
[[To[mock:checkpoint.after]]]]

Excerpt of BadRouteTest logs:
23:44:45,740 INFO             -            - AdviceWithTasks
 - AdviceWith (checkpoint) : [To[mock:checkpoint]] --> before [pipeline ->
[[To[mock:checkpoint.before]]]]
23:44:45,740 INFO             -            - AdviceWithTasks
 - AdviceWith (checkpoint) : [To[mock:checkpoint]] --> before [pipeline ->
[[To[mock:checkpoint.before]]]]
23:44:45,740 INFO             -            - AdviceWithTasks
 - AdviceWith (checkpoint) : [To[mock:checkpoint]] --> after [pipeline ->
[[To[mock:checkpoint.after]]]]
23:44:45,740 INFO             -            - AdviceWithTasks
 - AdviceWith (checkpoint) : [To[mock:checkpoint]] --> after [pipeline ->
[[To[mock:checkpoint.after]]]]


Is this a bug or am I doing something wrong?

Reply via email to