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

Exeptions cannot be propagated to the parent route when using LogEIP

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.7.1
    • 2.8.1, 2.9.0
    • camel-core
    • None
    • Unknown

    Description

      Here is unit test that demonstrates the problem.
      For the unit test pass successfully it's necessary to delete LogEIP from the route.

      package org.apache.camel.impl;
      
      import org.apache.camel.Exchange;
      import org.apache.camel.Processor;
      import org.apache.camel.builder.RouteBuilder;
      import org.apache.camel.test.junit4.CamelTestSupport;
      import org.junit.Test;
      
      public class PropagateExceptionTest extends CamelTestSupport {
      
          @Test
          public void failure() throws Exception {
              getMockEndpoint("mock:handleFailure").whenAnyExchangeReceived(new Processor() {
                  @Override
                  public void process(Exchange exchange) throws Exception {
                      throw new RuntimeException("TEST EXCEPTION");
                  }
              });
      
              getMockEndpoint("mock:exceptionFailure").expectedMessageCount(1);
              sendBody("direct:startFailure", "Hello World");
              assertMockEndpointsSatisfied();
          }
      
          @Test
          public void success() throws Exception {
              getMockEndpoint("mock:handleSuccess").whenAnyExchangeReceived(new Processor() {
                  @Override
                  public void process(Exchange exchange) throws Exception {
                      throw new RuntimeException("TEST EXCEPTION");
                  }
              });
      
              getMockEndpoint("mock:exceptionSuccess").expectedMessageCount(1);
              sendBody("direct:startSuccess", "Hello World");
              assertMockEndpointsSatisfied();
          }
      
          @Override
          protected RouteBuilder[] createRouteBuilders() throws Exception {
              return new RouteBuilder[] {
                      new RouteBuilder() {
                          public void configure() throws Exception {
                              from("direct:startFailure")
                                  .onException(Throwable.class)
                                      .to("mock:exceptionFailure")
                                      .end()
                                  .to("direct:handleFailure")
                                  .to("mock:resultFailure");
      
                              from("direct:handleFailure")
                                  .errorHandler(noErrorHandler())
                                  .log("FAULTY LOG")
                                  .to("mock:handleFailure");
                          }
                      },
      
                      new RouteBuilder() {
                          public void configure() throws Exception {
                              from("direct:startSuccess")
                                  .onException(Throwable.class)
                                      .to("mock:exceptionSuccess")
                                      .end()
                                  .to("direct:handleSuccess")
                                  .to("mock:resultSuccess");
      
                              from("direct:handleSuccess")
                                  .errorHandler(noErrorHandler())
                                  .to("mock:handleSuccess");
                          }
                      }
              };
          }
      }
      

      Attachments

        1. LogProcessor.patch
          0.4 kB
          Sergey Zhemzhitsky

        Activity

          People

            davsclaus Claus Ibsen
            szhemzhitsky Sergey Zhemzhitsky
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: