camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (JIRA)" <j...@apache.org>
Subject [jira] [Assigned] (CAMEL-9558) DefaultErrorHandler logs despite "handled true"
Date Fri, 05 Feb 2016 15:01:39 GMT

     [ https://issues.apache.org/jira/browse/CAMEL-9558?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Claus Ibsen reassigned CAMEL-9558:
----------------------------------

    Assignee: Claus Ibsen

> DefaultErrorHandler logs despite "handled true"
> -----------------------------------------------
>
>                 Key: CAMEL-9558
>                 URL: https://issues.apache.org/jira/browse/CAMEL-9558
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.16.2
>            Reporter: Andreas Siepert
>            Assignee: Claus Ibsen
>
> The *assumption* is that handled exceptions will not be propagated any further.
> In version {{2.15.5}} the test code (from the camel-jetty page) runs fine - but since
{{2.16.0}} the handled exception is propagated to the {{DefaultErrorHandler}} which causes
ERROR logs for every handled exception.
> I could not find a hint in the release notes - so I think it's a bug.
> {code}
> public class MyTest extends CamelTestSupport {
>     @Test
>     public void test() throws Exception {
>         // using httpclient 4.3.5
>         CloseableHttpClient httpclient = HttpClients.createDefault();
>         HttpGet httRequest = new HttpGet("http://127.0.0.1:7890/myserver");
>         HttpResponse response = httpclient.execute(httRequest);
>         assertThat(response.getStatusLine().getStatusCode(), is(500));
>     }
>     @Override
>     protected RouteBuilder createRouteBuilder() throws Exception {
>         return new RouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 from("jetty://http://localhost:7890/myserver").tracing()
>                         // use onException to catch all exceptions and return a custom
reply message
>                         .onException(Exception.class).handled(true)
>                         // create a custom failure response
>                         .transform(constant("Dude something went wrong"))
>                         // we must remember to set error code 500 as handled(true)
>                         // otherwise would let Camel thing its a OK response (200)
>                         .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(500)).end()
>                         // now just force an exception immediately
>                         .throwException(new IllegalArgumentException("I cannot do this"));
>             }
>         };
>     }
> }
> {code}
> *References from the user-list*
> http://camel.465427.n5.nabble.com/onException-block-in-camel-2-16-1-td5777019.html#a5777064
> http://camel.465427.n5.nabble.com/jetty-handled-true-not-working-as-before-td5776774.html



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message