We are currently building our own product and framework. We have a rule engine which internally uses MVEL API to evaluate expressions.

Recently we encountered one issue

Let say i have a "Rule", with lot of conditions in a nested way.

( A && ( B && ( C && ( D && ( E && F ) ) ) ) )

Let say i have more longer expression like above. Instead of A,B,C etc i have ognl's like (A -> contextObjectLoanApplication.Customer.personinfo.age)

If i compile this expression, it takes almost 3-4 hrs to compile a expression. Is there a way out where i can set anything in parser or context and MVEL handles it in a more optimized way.

We are almost stuck here, either we may need to change the whole API which generates this expression and then compile.

So just curious if MVEL can handle this.

Thanks

有帮助吗?

解决方案

MVEL's parser is naïve or broken, and parses such expressions in exponential time with respect to the parentheses depth:

(A && (B && (C && (D && (E && F)))))

There's nothing you can do about it unless they fix their parser, which is unlikely.

The following nested expressions are parsed exponentially as well:

(A ? B : (C ? D : (E ? F : (G ? H : (I ? J : K)))))

(As of MVEL 2.1.7)

其他提示

Issue has been opened in MVEL-301

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top