-
Bug
-
Resolution: Done
-
Major
-
None
-
None
-
-
Undefined
-
NEW
-
NEW
When building and executing a rule that is written in MVEL dialect and contains a statement ending with a new line character (not semi-colon) in action part with executable model enabled, we sometimes encounter some compilation error or unexpected result.
- Example 1 (rule "rule22a1" in reproducer_model_compiler_22a)
This rule (*1) contains a statement ending with a new line character (*1-1). When building this rule, model compiler generates java code like (*2) from the action part and the generated code causes a compilation error like (*3).
(*1)package com.example.reproducer import java.math.BigDecimal dialect "mvel" rule "rule22a1" when $bus : Bus( $weight : weight != 0 ) then System.out.println("***** Action of rule22a1: " + $bus + ", $weight = " + $weight); $weight = $weight // .......... (*1-1) BigDecimal bd1 = 0; modify($bus) { weight = bd1 } end
(*2)
System.out.println("***** Action of rule22a1: " + $bus + ", $weight = " + $weight); $weight = new java.math.BigDecimal(0); // ..... (*2-1) $bus.setWeight(bd1); drools.update($bus, mask_$bus);
(*3)
17:28:50.182 [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile-1) @ reproducer_model_compiler_22a --- 17:28:50.185 [INFO] Changes detected - recompiling the module! 17:28:50.186 [INFO] Compiling 9 source files to /work2/testdir/reproducer_model_compiler_22a/target/classes 17:28:50.459 [INFO] ------------------------------------------------------------- 17:28:50.459 [ERROR] COMPILATION ERROR : 17:28:50.459 [INFO] ------------------------------------------------------------- 17:28:50.459 [ERROR] /work2/testdir/reproducer_model_compiler_22a/target/generated-sources/drools-model-compiler/main/java/com/example/reproducer/P7C/LambdaConsequence7CD56D82A4775FB5FC32E4022E4511B5.java:[25,24] cannot find symbol symbol: variable bd1 location: class com.example.reproducer.P7C.LambdaConsequence7CD56D82A4775FB5FC32E4022E4511B5 17:28:50.460 [INFO] 1 error 17:28:50.460 [INFO] -------------------------------------------------------------
- Example 2 (rule "rule22a2" in reproducer_model_compiler_22a)
This rule (*4) contains a statement ending with a new line character (*4-1). When building this rule, model compiler generates java code like (*5) from the action part. The generated code does not cause a compilation error but causes unexpected result at runtime like (*6).
(*4)rule "rule22a2" when $bus : Bus( $weight : weight != 0, $capacity : capacity != 0 ) then System.out.println("***** Action of rule22a2: " + $bus + ", $weight = " + $weight + ", $capacity = " + $capacity); $weight = $weight // .......... (*4-1) BigDecimal bd1 = $capacity; modify($bus) { weight = $weight } end
(*5)
System.out.println("***** Action of rule22a2: " + $bus + ", $weight = " + $weight + ", $capacity = " + $capacity); $weight = new java.math.BigDecimal($capacity); ..... (*5-1) $bus.setWeight($weight); drools.update($bus, mask_$bus);
(*6)
***** start ***** Action of rule22a2: com.example.reproducer.Bus@7b64240d, $weight = 12000, $capacity = 25 ***** Action of rule22a2: com.example.reproducer.Bus@7b64240d, $weight = 25, $capacity = 25 ***** Action of rule22a2: com.example.reproducer.Bus@7b64240d, $weight = 25, $capacity = 25 ***** Action of rule22a2: com.example.reproducer.Bus@7b64240d, $weight = 25, $capacity = 25 ***** Action of rule22a2: com.example.reproducer.Bus@7b64240d, $weight = 25, $capacity = 25 ***** Action of rule22a2: com.example.reproducer.Bus@7b64240d, $weight = 25, $capacity = 25 ***** Action of rule22a2: com.example.reproducer.Bus@7b64240d, $weight = 25, $capacity = 25 ***** Action of rule22a2: com.example.reproducer.Bus@7b64240d, $weight = 25, $capacity = 25 ***** Action of rule22a2: com.example.reproducer.Bus@7b64240d, $weight = 25, $capacity = 25 ***** Action of rule22a2: com.example.reproducer.Bus@7b64240d, $weight = 25, $capacity = 25 ***** end
Java code generated by model compiler (*2-1) and (*5-1) are both $weight = <RHS of the next assignment statement> and incorrect.
In plain drl, both of these examples are successfully built and executed as expected.
- clones
-
RHDM-1622 Statement ending with a new line character (not semi-colon) in action part causes compilation error or unexpected result in executable model.
- Closed