henka-rl commented on pull request #6267:
URL: https://github.com/apache/camel/pull/6267#issuecomment-942387730


   I tried to solve the issue with parsing exception in init like this:
   `    @Override
       public <T> T evaluate(Exchange exchange, Class<T> type) {
           if (expressionException == null) {
               return expression.evaluate(exchange, type);
           } else {
               throw expressionException;
           }
       }
   
       @Override
       public boolean matches(Exchange exchange) {
           if (predicateException == null) {
               return predicate.matches(exchange);
           } else {
               throw predicateException;
           }
       }
   
       @Override
       public void init(CamelContext context) {
           simple = context.resolveLanguage("simple");
           text = context.resolvePropertyPlaceholders(text);
   
           try {
               if (resultType != null) {
                   Object[] properties = new Object[2];
                   properties[0] = resultType;
                   expression = simple.createExpression(text, properties);
               } else {
                   expression = simple.createExpression(text);
               }
               expression.init(context);
           } catch (RuntimeCamelException e) {
               expressionException = e;
           }
           try {
               predicate = simple.createPredicate(text);
               predicate.init(context);
           } catch (RuntimeCamelException e) {
               predicateException = e;
           }
       }`
   But not all testcases pass anyway as it looks like init() is not called 
before the first call to evaluate() or matches()
       


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to