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

[consumer.]bridgeErrorHandler doesn't handle exception thrown by startingDirectoryMustExist

    XMLWordPrintableJSON

    Details

      Description

      Following StackOverflow: File component's [consumer.]bridgeErrorHandler in conjunction with startingDirectoryMustExist I created the following test class:

      package test;
      
      import org.apache.camel.LoggingLevel;
      import org.apache.camel.builder.RouteBuilder;
      import org.apache.camel.main.Main;
      import org.junit.After;
      import org.junit.Before;
      import org.junit.Test;
      
      public class CamelBridgeErrorHandlerTest {
      
        private Main main;
      
        @Before
        public void before() {
          main = new Main();
        }
      
        @Test
        public void bridgeErrorHandler() {
          main.addRouteBuilder(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
              route(this, "file:not.existing.dir?autoCreate=false&startingDirectoryMustExist=true&bridgeErrorHandler=true");
            }
          });
        }
      
        @Test
        public void consumerBridgeErrorHandler() {
          main.addRouteBuilder(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
              route(this, "file:not.existing.dir?autoCreate=false&startingDirectoryMustExist=true&consumer.bridgeErrorHandler=true");
            }
          });
        }
      
        private void route(final RouteBuilder builder, final String consumerURI) {
          builder
              .from(consumerURI)
      
              // this is never reached
              .onException(Exception.class)
              .handled(true)
              .log(LoggingLevel.ERROR, "${exception}")
              .end()
      
              .log(" ... processing ...");
        }
      
        @After
        public void after() throws Exception {
          main.start();
        }
      }
      

      Both test methods throw:

      org.apache.camel.FailedToCreateRouteException: Failed to create route routeN:
        Route(routeN)[[From[file:not.existing.dir?autoCreate=false&s...
          because of Starting directory does not exist: not.existing.dir
      

      rather than the exception(s) being handled by the route(s)' onException().


      P.S.: When TRACEing through the log output both test methods show:

      2019-02-08 11:29:36.209 TRACE camel.model.ProcessorDefinitionHelper – There are 6 properties on: From[file:not.existing.dir?autoCreate=false&startingDirectoryMustExist=true&{consumer.}bridgeErrorHandler=true]

      while there are just 3 of them (autoCreate, startingDirectoryMustExist, [consumer.]bridgeErrorHandler), aren't there? Is this worth another issue?

        Attachments

          Activity

            People

            • Assignee:
              davsclaus Claus Ibsen
              Reporter:
              Broser Gerold Broser
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: