Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-20778

Intercept created using AdviceWithRouteBuilder causes issues with error handling (regression)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 4.4.3, 4.7.0
    • camel-core
    • None
    • Unknown

    Description

      Starting from Camel 4.0.0. It works with 3.22.x and below.

      Reproducer: https://github.com/DenisIstomin/camel-intercept-bug

      If route is configured like this:

          public void configure() {
              onException(Exception.class)
                      .log(LoggingLevel.ERROR, "handler", "called");
      
              from("direct:start").routeId("main-route-id")
                .doTry()
                  .throwException(new Exception())
                .doCatch(Exception.class)
                  .setBody(constant("expected"))
                .end();
          }
      

      And then this route is adviced:

              AdviceWith.adviceWith(context, "main-route-id", routeBuilder -> {
                  routeBuilder.intercept().log("intercepted");
              });
      

       
      Error handler will not catch an exception. Body will not be equal to "expected".
      XML:

      <route xmlns="http://camel.apache.org/schema/spring" id="main-route-id">
          <from uri="direct:start"/>
          <onException>
              <exception>java.lang.Exception</exception>
              <log logName="handler" message="called" loggingLevel="ERROR"/>
          </onException>
          <intercept>
              <log message="intercepted"/>
          </intercept>
          <doTry>
              <throwException/>
              <doCatch>
                  <exception>java.lang.Exception</exception>
                  <setBody>
                      <constant>expected</constant>
                  </setBody>
              </doCatch>
          </doTry>
      </route>
      

      Attachments

        Issue Links

          Activity

            People

              davsclaus Claus Ibsen
              DenisIstomin Denis Istomin
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: