You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@nutch.apache.org by Max Ockner <ma...@gmail.com> on 2021/10/10 22:30:14 UTC
JEXL unable to handle "if" statements?
Hello,
I'm trying to use JEXL expressions similar to the ones described here
https://issues.apache.org/jira/browse/NUTCH-2368.
I consistently get an error parsing my "if" statement.
I can reproduce with a simpler expression:
-Dgenerate.max.count.expr='if (true) {return 2} else {return 1}'
I'm running 1.19 on java 11 (also tried with java 8).
Has anyone else seen this problem?
Thanks,
Ma
Re: JEXL unable to handle "if" statements?
Posted by Sebastian Nagel <wa...@googlemail.com.INVALID>.
Hi Max,
fyi, the Jira issue is created:
https://issues.apache.org/jira/browse/NUTCH-2902
(to make sure that this is not forgotten)
Thanks,
Sebastian
On 10/11/21 18:11, Sebastian Nagel wrote:
> Hi Max,
>
>> I was able to fix this by switching from JexlExpression to JexlScript. I
>> have a small patch that I'm happy to contribute!
>
> Yes, that would be great! Please open also a Jira issue so that the
> problem shows up in the Changelog.
>
> Thanks!
>
> Best,
> Sebastian
>
> On 10/11/21 6:34 AM, Max Ockner wrote:
>> According to the commons-jexl change logs, a breaking change was released
>> in 3.0:
>>
>> "Syntactically enforce that expressions do not contain statements:
>> POTENTIAL EXPRESSION BREAK! (ie an expression is not a script and can NOT
>> use 'if','for'... and blocks)"
>>
>> I was able to fix this by switching from JexlExpression to JexlScript. I
>> have a small patch that I'm happy to contribute!
>>
>>
>>
>> On Sun, Oct 10, 2021 at 3:30 PM Max Ockner <ma...@gmail.com> wrote:
>>
>>> Hello,
>>>
>>> I'm trying to use JEXL expressions similar to the ones described here
>>> https://issues.apache.org/jira/browse/NUTCH-2368.
>>>
>>> I consistently get an error parsing my "if" statement.
>>>
>>> I can reproduce with a simpler expression:
>>> -Dgenerate.max.count.expr='if (true) {return 2} else {return 1}'
>>>
>>> I'm running 1.19 on java 11 (also tried with java 8).
>>>
>>> Has anyone else seen this problem?
>>>
>>> Thanks,
>>> Ma
>>>
>>
>
Re: JEXL unable to handle "if" statements?
Posted by Sebastian Nagel <wa...@googlemail.com.INVALID>.
Hi Max,
> I was able to fix this by switching from JexlExpression to JexlScript. I
> have a small patch that I'm happy to contribute!
Yes, that would be great! Please open also a Jira issue so that the
problem shows up in the Changelog.
Thanks!
Best,
Sebastian
On 10/11/21 6:34 AM, Max Ockner wrote:
> According to the commons-jexl change logs, a breaking change was released
> in 3.0:
>
> "Syntactically enforce that expressions do not contain statements:
> POTENTIAL EXPRESSION BREAK! (ie an expression is not a script and can NOT
> use 'if','for'... and blocks)"
>
> I was able to fix this by switching from JexlExpression to JexlScript. I
> have a small patch that I'm happy to contribute!
>
>
>
> On Sun, Oct 10, 2021 at 3:30 PM Max Ockner <ma...@gmail.com> wrote:
>
>> Hello,
>>
>> I'm trying to use JEXL expressions similar to the ones described here
>> https://issues.apache.org/jira/browse/NUTCH-2368.
>>
>> I consistently get an error parsing my "if" statement.
>>
>> I can reproduce with a simpler expression:
>> -Dgenerate.max.count.expr='if (true) {return 2} else {return 1}'
>>
>> I'm running 1.19 on java 11 (also tried with java 8).
>>
>> Has anyone else seen this problem?
>>
>> Thanks,
>> Ma
>>
>
Re: JEXL unable to handle "if" statements?
Posted by Max Ockner <ma...@gmail.com>.
According to the commons-jexl change logs, a breaking change was released
in 3.0:
"Syntactically enforce that expressions do not contain statements:
POTENTIAL EXPRESSION BREAK! (ie an expression is not a script and can NOT
use 'if','for'... and blocks)"
I was able to fix this by switching from JexlExpression to JexlScript. I
have a small patch that I'm happy to contribute!
On Sun, Oct 10, 2021 at 3:30 PM Max Ockner <ma...@gmail.com> wrote:
> Hello,
>
> I'm trying to use JEXL expressions similar to the ones described here
> https://issues.apache.org/jira/browse/NUTCH-2368.
>
> I consistently get an error parsing my "if" statement.
>
> I can reproduce with a simpler expression:
> -Dgenerate.max.count.expr='if (true) {return 2} else {return 1}'
>
> I'm running 1.19 on java 11 (also tried with java 8).
>
> Has anyone else seen this problem?
>
> Thanks,
> Ma
>