The use of the four basic binary operators taking BigDecimal operand(s) causes a compilation error in executable model.
Issue
Building a rule which is described in MVEL dialect and uses one of the four basic binary operators (+
, -
, *
, /
) taking one or two BigDecimal type value(s) as operand(s) with executable rule models enabled causes a compilation error.
For example, in the following rule,
package com.example.reproducer
import com.example.reproducer.Bus
import java.math.BigDecimal
dialect "mvel"
rule "bus3b"
when
$bus : Bus()
then
BigDecimal grossWeight = $bus.weight + $bus.capacity * 55 + $bus.maxLoadingWeight; // ..... (*1)
System.out.println("***** " + $bus + ", gross weight = " + grossWeight);
end
// $bus.weight and $bus.maxLoadingWeight are BigDecimal type properties, and $bus.capacity is an int type property of Bus class.
the expression $bus.weight + $bus.capacity * 55
in the statement (*1) performs an addition of BigDecimal type value ($bus.weight
) and numeric value (the result of $bus.capacity * 55
).
When I build a maven project which contains this rule with executable model enabled, a compilation error occurs with the message like below.
$ mvn clean compile -DgenerateModel=YES
...
[ERROR] /work2/testdir/reproducer_model_compiler_3b/target/generated-sources/drools-model-compiler/main/java/com/example/reproducer/P3B/LambdaConsequence3B6B2D15753A225FFA39E42DED953773.java:[18,61] bad operand types for binary operator '+'
first type: java.math.BigDecimal
second type: int
...
This issue occurs for the following operations:
- BigDecimal_type_value op Numeric_value
- Numeric_value op BigDecimal_type_value
- BigDecimal_type_value op BigDecimal_type_value
where op is one of the binary operators +
, -
, *
, /
.
Environment
- Red Hat Decision Manager (RHDM)
- 7.5.0 - 7.9.1
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.