Camel
  1. Camel
  2. CAMEL-4513

simple predicate fails to introspect the exception in an onException clause using onWhen

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.8.3, 2.9.0
    • Component/s: camel-core
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      The bug occured in the 2.6.0 version of Camel I'm using. I haven't test it against the latest version but I've checked the sources and it doesn't seem to have change since.

      Given a camel route, with a onException clause like this :

      this.onException(MyException.class)
          .onWhen(simple("${exception.myExceptionInfo.aValue} == true"))
          ...
      

      MyException is a customed exception like this :

      MyException.java
      public class MyException extends Exception {
         ....
         public MyExceptionInfo getMyExceptionInfo() {
           ...
         }
      }
      

      What I've observed is that when BeanExpression.OgnlInvokeProcessor.process iterate through the methods to calls, it does :

                      // only invoke if we have a method name to use to invoke
                      if (methodName != null) {
                          InvokeProcessor invoke = new InvokeProcessor(holder, methodName);
                          invoke.process(resultExchange);
      
                          // check for exception and rethrow if we failed
                          if (resultExchange.getException() != null) {
                              throw new RuntimeBeanExpressionException(exchange, beanName, methodName, resultExchange.getException());
                          }
      
                          result = invoke.getResult();
                      }
      

      It successfully invoke the method : invoke.process(resultExchange);
      But it checks for exception in the exchange. Since we are in an exception clause, there is an actual exception (thrown by the application, but unrelated with the expression language search) and it fails

      There is a simple workaround for that : writing his own predicate class to test wanted conditions

        Issue Links

          Activity

          Hide
          Claus Ibsen added a comment -

          Thanks for reporting.

          Show
          Claus Ibsen added a comment - Thanks for reporting.

            People

            • Assignee:
              Claus Ibsen
              Reporter:
              Thomas Gueze
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development