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

Gerold Broser updated CAMEL-13174:
----------------------------------
    Description: 
Following [StackOverflow: _File component's [consumer.]bridgeErrorHandler in 
conjunction with startingDirectoryMustExist_ 
|https://stackoverflow.com/questions/54513101/file-components-consumer-bridgeerrorhandler-in-conjunction-with-startingdirec]
 I created the following test class:
{code:java}
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();
  }
}
{code}
Both test methods throw:
{noformat}
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
{noformat}
rather than the exception(s) being handled by the route(s)' {{onException()}}.
----
P.S.: When TRACEing through the log output both test methods show:
{quote}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]
{quote}
while there are just 3 of them ({{autoCreate}}, {{startingDirectoryMustExist}}, 
{{[consumer.]bridgeErrorHandler}}), aren't there? Is this worth another issue?

  was:
Following [StackOverflow: _File component's \[consumer.\]bridgeErrorHandler in 
conjunction with startingDirectoryMustExist_ 
|https://stackoverflow.com/questions/54513101/file-components-consumer-bridgeerrorhandler-in-conjunction-with-startingdirec]
 I created the following test class:
{code:java}
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();
  }
}
{code}
Both test methods throw:
{noformat}
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
{noformat}

rather than the exception(s) being handled by the route(s)' {{onException()}}.
----
P.S.: When TRACEing through the log output both test methods show:

{quote}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\]
{quote}

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


> [consumer.]bridgeErrorHandler doesn't handle exception thrown by 
> startingDirectoryMustExist
> -------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-13174
>                 URL: https://issues.apache.org/jira/browse/CAMEL-13174
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.23.1
>            Reporter: Gerold Broser
>            Priority: Critical
>              Labels: camel-file, consumer, exception-handling
>
> Following [StackOverflow: _File component's [consumer.]bridgeErrorHandler in 
> conjunction with startingDirectoryMustExist_ 
> |https://stackoverflow.com/questions/54513101/file-components-consumer-bridgeerrorhandler-in-conjunction-with-startingdirec]
>  I created the following test class:
> {code:java}
> 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();
>   }
> }
> {code}
> Both test methods throw:
> {noformat}
> 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
> {noformat}
> rather than the exception(s) being handled by the route(s)' {{onException()}}.
> ----
> P.S.: When TRACEing through the log output both test methods show:
> {quote}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]
> {quote}
> while there are just 3 of them ({{autoCreate}}, 
> {{startingDirectoryMustExist}}, {{[consumer.]bridgeErrorHandler}}), aren't 
> there? Is this worth another issue?



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to