You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (JIRA)" <ji...@apache.org> on 2016/02/05 16:57:39 UTC
[jira] [Resolved] (CAMEL-9558) DefaultErrorHandler logs despite
"handled true"
[ https://issues.apache.org/jira/browse/CAMEL-9558?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen resolved CAMEL-9558.
--------------------------------
Resolution: Fixed
Thanks for reporting.
> 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
> Fix For: 2.16.3, 2.17.0
>
>
> 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)