You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2024/01/17 10:49:00 UTC
[jira] [Commented] (CAMEL-20337) Syntax check of simple expression in filter eip is stricter than using validation
[ https://issues.apache.org/jira/browse/CAMEL-20337?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17807686#comment-17807686 ]
Claus Ibsen commented on CAMEL-20337:
-------------------------------------
Not a bug.
predicate vs expression is not the same for some languages like simple.
> Syntax check of simple expression in filter eip is stricter than using validation
> ----------------------------------------------------------------------------------
>
> Key: CAMEL-20337
> URL: https://issues.apache.org/jira/browse/CAMEL-20337
> Project: Camel
> Issue Type: Bug
> Components: camel-core
> Affects Versions: 3.20.9
> Reporter: Raymond
> Priority: Minor
>
> I have the following Simple expression:
> {code:java}
> ${header.randomString} !='' {code}
> When I check this expression with the following code:
> {code:java}
> public ValidationErrorMessage validate(Expression expression){
> try {
> SimpleLanguage.simple(expression.getExpression());
> } catch (SimpleIllegalSyntaxException e) {
> if(expression.getName() == null) {
> return new ValidationErrorMessage(e.getMessage());
> }
> return new ValidationErrorMessage("[" + expression.getName() + "]: " + e.getMessage());
> }
> return null;
> } {code}
> It returns OK without a syntax error.
> When I use it in the following route:
> {code:java}
> <route id="setheader">
> <from uri="direct:in"/>
> <setHeader headerName="header">
> <simple>${header.randomString} !=''</simple>
> </setHeader>
> <to uri="direct:out"/>
> </route> {code}
> It also goes well.
> But when I use it in a route with a filter:
> {code:java}
> <route id="routewithfilter">
> <from uri="direct:in"/>
> <filter>
> <simple>${header.randomString} !=''</simple>
> <to uri="direct:out"/>
> </filter>
> </route> {code}
> Then I get a syntax error on installation:
> {code:java}
> Failed to create route routewithfilter at: >>> Filter[simple{${header.randomString} !=''} -> [To[direct:in]]] <<< in route: Route(routewithfilter ...because of expected symbol whiteSpace but was singleQuote at location 25\n${header.randomString} !=''\n *\n {code}
> The error is easily solved by adding the expected whitespace:
> {code:java}
> <simple>${header.randomString} != ''</simple> {code}
> My question is, why doesn't work everywhere the same? Is there an explanation for this or is it a bug?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)