Hi,

we’ve got a problem with the changes for CAMEL-7560. Since an upgrade from
2.12.2 to 2.12.5 all tests where we use the weaveAddFirst method to advice
routes with an onException-clause failed with the following
IllegalArgumentException:

"java.lang.IllegalArgumentException: There are no outputs which matches:
..."

The reason is that the call "outputs.get(0).getOutputs();" in
AdviceWithTasks for an OnExceptionDefinition only returns the onException
part of the route. I've added a test in AdviceWithTasksTest to demonstrate
it:

public void testBeforeWithOnException() throws Exception {
        context.addRoutes(new RouteBuilder() {
            
            @Override
            public void configure() throws Exception {
                from("direct:start2")
                .onException(Throwable.class).handled(true).end()
                .to("mock:foo")
                .to("mock:bar")
                .id("bar2")
                .to("mock:result");;
                
            }
        });
        // START SNIPPET: e3
        context.getRouteDefinitions().get(1).adviceWith(context, new
AdviceWithRouteBuilder() {
            @Override
            public void configure() throws Exception {
                // weave the node in the route which has id = bar
                // and insert the following route path before the adviced
node
               
weaveById("bar2").before().to("mock:a").transform(constant("Bye World"));
            }
        });
        // END SNIPPET: e3

        getMockEndpoint("mock:foo").expectedBodiesReceived("Hello World");
        getMockEndpoint("mock:a").expectedBodiesReceived("Hello World");
        getMockEndpoint("mock:bar").expectedBodiesReceived("Bye World");
        getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");

        template.sendBody("direct:start2", "Hello World");

        assertMockEndpointsSatisfied();
}

Is there any need why it’s for any abstract definition? If I change the
premise in AdviceWithTasks.getParentOutputs from
"outputs.get(0).isAbstract()" to "outputs.get(0) instanceof
TransactedDefinition" all tests passed. Enclosed you will find my svn patch.

Greeting

Dennis

AdviceWithTasks_Patch.txt
<http://camel.465427.n5.nabble.com/file/n5761437/AdviceWithTasks_Patch.txt>  



--
View this message in context: 
http://camel.465427.n5.nabble.com/Problem-with-adviceWith-on-2-13-x-tp5752421p5761437.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to