You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2021/10/13 18:38:00 UTC
[GitHub] [camel] henka-rl edited a comment on pull request #6267: CAMEL-17075 Moved initialisation from evaluate() to init()
henka-rl edited a comment 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 always 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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org