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

null body after exception from transform method

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.15.2
    • 2.15.3, 2.16.0
    • camel-core
    • None
    • Unknown

    Description

      When an exception is thrown from a transform method I lose the content of the message body. This behaviour is unexpected because it does not happen when an exception is thrown from a bean call.

      .bean(ErrorBean.class, ErrorBean.METHOD)
      Vs.
      .transform().method(ErrorBean.class, ErrorBean.METHOD)

      I have a testcase that I will try to get attached but here are the routes:

      if ("testTransformExceptionToErrorRoute".equals(getTestMethodName())) {
                          from(START)
                          .routeId("exception.test.transform")
                          .transform().method(ErrorBean.class, ErrorBean.METHOD)
                          .to(END);
                      } else {
                          from(START)
                          .routeId("exception.test.bean")
                          .bean(ErrorBean.class, ErrorBean.METHOD)
                          .to(END);
                      }
      
          public static class ErrorBean {
              private static final String METHOD = "throwException";
              public static void throwException(Exchange exchange) {
                  String body = exchange.getIn().getBody(String.class);
                  Assertions.assertThat(body).isEqualTo(BODY);
                  throw new NullPointerException();
              }
          }
      

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            HansO Hans Orbaan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: