Details
-
Bug
-
Resolution: Done
-
Major
-
5.2.0.Final, 5.3.0.Final
-
None
Description
Drools 5.2.0/5.3.0 throws a parse error against the following rule while 5.1.0 can parse it. FactA.value is a BigDecimal.
rule "99.99B" dialect "mvel" when $a : FactA( value == (99.99B) ) then System.out.println( "Hit 99.99B : " + $a.value.toString() ); end
[8,23]: [ERR 101] Line 8:23 no viable alternative at input '(' in rule "99.99B" [0,0]: Parser returned a null Package java.lang.IllegalArgumentException: Could not parse knowledge. at com.sample.DroolsTest.readKnowledgeBase(DroolsTest.java:50) at com.sample.DroolsTest.main(DroolsTest.java:25)
Attached an example which includes DroolsTest.java/Sample.drl which demonstrates this. MvelTest.java demonstrates mvel itself works as expected.
Note from Edson:
The short answer is: Drools 5.2 does not support the literal sufixes B for BigDecimal and I for BigInteger. The long answer is: Drools is implementing more strict semantics for compilation, in order to provide better feedback at compile time reducing errors at runtime. Up to Drools 5.1, anything between () in an expression was ignored by Drools and passed through to the underlying expression evaluator (MVEL). MVEL has support for B and I sufixes. Drools 5.2 improved the parser in order to own 100% of the DRL syntax and now it does not bypass anything in a DRL file. This has advantages and disadvantages, one of which is that if it is not in the DRL grammar, it will not compile, as Drools can not guarantee the runtime semantics of it.
So this is an intentional change but I'm setting 'Type:' to "Bug" rather than "Feature Request" as it prevents users from migrating from older version.