You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Nick Outram <ap...@nickoutram.name> on 2007/08/17 12:49:24 UTC

Caught exceptions also proceed

For the following setup:

exception(InvocationTargetException.class).to("seda:error");

from("direct:in").beanRef("myBean").to(direct:out);

If "myBean" raises an InvocationTargetException the message ends up on both
seda:error and direct:out.
This shouldn't be the default behaviour. To get this behaviour I would
expect to use:

exception(InvocationTargetException.class).to("seda:error").proceed();
-- 
View this message in context: http://www.nabble.com/Caught-exceptions-also-proceed-tf4285006s22882.html#a12197578
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Caught exceptions also proceed

Posted by Nick Outram <ap...@nickoutram.name>.
Hmm, which build are you using Neil? I just tried this on the nightly
snapshot and it works fine.


Neil Thorne (work) wrote:
> 
> I can confirm this is an issue. It is causing havoc with our routing. If
> an exception is thrown and we specify an exception(Exception.class) clause
> the route should not proceed to the original destination endpoint for the
> route.
> 
> Can we get a fix?
> 

-- 
View this message in context: http://www.nabble.com/Caught-exceptions-also-proceed-tf4285006s22882.html#a12742600
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Caught exceptions also proceed

Posted by "Neil Thorne (work)" <ne...@travelex.com>.
I can confirm this is an issue. It is causing havoc with our routing. If an
exception is thrown and we specify an exception(Exception.class) clause the
route should not proceed to the original destination endpoint for the route.

Can we get a fix?
-- 
View this message in context: http://www.nabble.com/Caught-exceptions-also-proceed-tf4285006s22882.html#a12659872
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Caught exceptions also proceed

Posted by Nick Outram <ap...@nickoutram.name>.
It looks like this one has been resolved, at least in trunk.

Good work James.

Thanks.


James.Strachan wrote:
> 
> On 8/21/07, Nick Outram <ap...@nickoutram.name> wrote:
>>
>>
>>
>> James.Strachan wrote:
>> >
>> > On 8/17/07, Nick Outram <ap...@nickoutram.name> wrote:
>> >> For the following setup:
>> >>
>> >> exception(InvocationTargetException.class).to("seda:error");
>> >>
>> >> from("direct:in").beanRef("myBean").to(direct:out);
>> >>
>> >> If "myBean" raises an InvocationTargetException the message ends up on
>> >> both
>> >> seda:error and direct:out.
>> >> This shouldn't be the default behaviour. To get this behaviour I would
>> >> expect to use:
>> >>
>> >> exception(InvocationTargetException.class).to("seda:error").proceed();
>> >
>> > Got a unit test case by any chance? :)
>> >
>> >
>> > --
>> > James
>> > -------
>> > http://macstrac.blogspot.com/
>> >
>> >
>>
>> Modify ValidationTest.testValidMessage() and
>> ValidationTest.testInvalidMessage() to:
>>
>>     public void testValidMessage() throws Exception {
>>         validEndpoint.expectedMessageCount(1);
>>         invalidEndpoint.expectedMessageCount(0);
>>
>>         template.sendBodyAndHeader("direct:start", "<valid/>", "foo",
>> "bar");
>>
>>         MockEndpoint.assertIsSatisfied(validEndpoint, invalidEndpoint);
>>     }
>>
>>     public void testInvalidMessage() throws Exception {
>>         invalidEndpoint.expectedMessageCount(1);
>>         validEndpoint.expectedMessageCount(0);
>>
>>         template.sendBodyAndHeader("direct:start", "<invalid/>", "foo",
>> "notMatchedHeaderValue");
>>
>>         MockEndpoint.assertIsSatisfied(validEndpoint, invalidEndpoint);
>>     }
>>
>> and run ValidationWithExceptionTest.java
>>
>> The first test passes, the second fails due to the validEndpoint
>> receiving
>> the message.
> 
> Thanks for the patch!
> 
> I'm wondering if this issue has been resolve in trunk; as I applied
> the patch you supplied and all the tests still pass for me.
> 
> I wonder could you double check I applied your change correctly?
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/Caught-exceptions-also-proceed-tf4285006s22882.html#a12742599
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Caught exceptions also proceed

Posted by James Strachan <ja...@gmail.com>.
On 8/21/07, Nick Outram <ap...@nickoutram.name> wrote:
>
>
>
> James.Strachan wrote:
> >
> > On 8/17/07, Nick Outram <ap...@nickoutram.name> wrote:
> >> For the following setup:
> >>
> >> exception(InvocationTargetException.class).to("seda:error");
> >>
> >> from("direct:in").beanRef("myBean").to(direct:out);
> >>
> >> If "myBean" raises an InvocationTargetException the message ends up on
> >> both
> >> seda:error and direct:out.
> >> This shouldn't be the default behaviour. To get this behaviour I would
> >> expect to use:
> >>
> >> exception(InvocationTargetException.class).to("seda:error").proceed();
> >
> > Got a unit test case by any chance? :)
> >
> >
> > --
> > James
> > -------
> > http://macstrac.blogspot.com/
> >
> >
>
> Modify ValidationTest.testValidMessage() and
> ValidationTest.testInvalidMessage() to:
>
>     public void testValidMessage() throws Exception {
>         validEndpoint.expectedMessageCount(1);
>         invalidEndpoint.expectedMessageCount(0);
>
>         template.sendBodyAndHeader("direct:start", "<valid/>", "foo",
> "bar");
>
>         MockEndpoint.assertIsSatisfied(validEndpoint, invalidEndpoint);
>     }
>
>     public void testInvalidMessage() throws Exception {
>         invalidEndpoint.expectedMessageCount(1);
>         validEndpoint.expectedMessageCount(0);
>
>         template.sendBodyAndHeader("direct:start", "<invalid/>", "foo",
> "notMatchedHeaderValue");
>
>         MockEndpoint.assertIsSatisfied(validEndpoint, invalidEndpoint);
>     }
>
> and run ValidationWithExceptionTest.java
>
> The first test passes, the second fails due to the validEndpoint receiving
> the message.

Thanks for the patch!

I'm wondering if this issue has been resolve in trunk; as I applied
the patch you supplied and all the tests still pass for me.

I wonder could you double check I applied your change correctly?

-- 
James
-------
http://macstrac.blogspot.com/

Re: Caught exceptions also proceed

Posted by Nick Outram <ap...@nickoutram.name>.


James.Strachan wrote:
> 
> On 8/17/07, Nick Outram <ap...@nickoutram.name> wrote:
>> For the following setup:
>>
>> exception(InvocationTargetException.class).to("seda:error");
>>
>> from("direct:in").beanRef("myBean").to(direct:out);
>>
>> If "myBean" raises an InvocationTargetException the message ends up on
>> both
>> seda:error and direct:out.
>> This shouldn't be the default behaviour. To get this behaviour I would
>> expect to use:
>>
>> exception(InvocationTargetException.class).to("seda:error").proceed();
> 
> Got a unit test case by any chance? :)
> 
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> 

Modify ValidationTest.testValidMessage() and
ValidationTest.testInvalidMessage() to:

    public void testValidMessage() throws Exception {
        validEndpoint.expectedMessageCount(1);
        invalidEndpoint.expectedMessageCount(0);

        template.sendBodyAndHeader("direct:start", "<valid/>", "foo",
"bar");

        MockEndpoint.assertIsSatisfied(validEndpoint, invalidEndpoint);
    }

    public void testInvalidMessage() throws Exception {
        invalidEndpoint.expectedMessageCount(1);
        validEndpoint.expectedMessageCount(0);

        template.sendBodyAndHeader("direct:start", "<invalid/>", "foo",
"notMatchedHeaderValue");

        MockEndpoint.assertIsSatisfied(validEndpoint, invalidEndpoint);
    }

and run ValidationWithExceptionTest.java

The first test passes, the second fails due to the validEndpoint receiving
the message.

-N
-- 
View this message in context: http://www.nabble.com/Caught-exceptions-also-proceed-tf4285006s22882.html#a12252463
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Caught exceptions also proceed

Posted by James Strachan <ja...@gmail.com>.
On 8/17/07, Nick Outram <ap...@nickoutram.name> wrote:
> For the following setup:
>
> exception(InvocationTargetException.class).to("seda:error");
>
> from("direct:in").beanRef("myBean").to(direct:out);
>
> If "myBean" raises an InvocationTargetException the message ends up on both
> seda:error and direct:out.
> This shouldn't be the default behaviour. To get this behaviour I would
> expect to use:
>
> exception(InvocationTargetException.class).to("seda:error").proceed();

Got a unit test case by any chance? :)


-- 
James
-------
http://macstrac.blogspot.com/