@Ingor

I gave it a try to what you proposed & indeed I could reproduce your issue,
right?

I see the log entry:
2011-12-08 16:19:56,093 [main           ] INFO  bar                           
- Error due Forced New

What I would expect would be:
2011-12-08 16:19:56,093 [main           ] INFO  foo                           
- Error due Forced New

I changed the unit test as following:

public class ContextScopedOnExceptionLogRouteTest extends ContextTestSupport
{
    
    public void testContextScopedOnExceptionLogRoute() throws Exception {
        getMockEndpoint("mock:foo").expectedMessageCount(1);
        getMockEndpoint("mock:bar").expectedMessageCount(0);
        getMockEndpoint("mock:result").expectedMessageCount(0);
        
        try {
            template.sendBody("direct:start", "Hello World");
            fail("Should have thrown exception");
        } catch (Exception e) {
            // ignore
        }

        assertMockEndpointsSatisfied();
    }

    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                onException(Exception.class)
                    .log("Error due ${exception.message}");
                
                from("direct:start").routeId("foo")
                    .to("mock:foo")
                    .throwException(new IllegalArgumentException("Forced
New"))
                    .to("direct:bar")
                    .to("mock:result");
                
                from("direct:bar").routeId("bar")
                    .to("mock:bar")
                    .throwException(new IllegalArgumentException("Forced"));
            }
        };
    }
}

Babak

--
View this message in context: 
http://camel.465427.n5.nabble.com/global-onException-clause-wrongly-identifies-route-in-which-exception-occurs-log-name-tp5058304p5059125.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to