Variable binding of a property of Map element causes unexpected result in executable model.
Issue
Building and executing a rule written in MVEL dialect that accesses a Map element and binds a property of the element to a variable in executable rule model, the bound variable is an unexpected value.
For example, when I build and execute a rule (*1) which uses a statement like (*1-1) with java code (*2) with executable rule models enabled,
(*1) rule
package com.example.reproducer
import com.example.reproducer.Car
dialect "mvel"
rule "rule1a3"
when
$car : Car( $supplierName : suppliers["transmission"].name ) // ..... (*1-1)
then
System.out.println("***** Action of rule1a3");
System.out.println("***** $car: " + $car + ", transmission supplier name = " + $supplierName);
end
// suppliers is a {{Map<String, Supplier>}} type property of Car class
(*2) java code
Car a = new Car("A180");
Map<String, Object> specs = new HashMap<>();
specs.put("transmission", "8-speed automatic");
a.setSpecifications(specs);
Map<String, String> parts = new HashMap<>();
parts.put("transmission", "T8SAT");
a.setPartNumbers(parts);
Map<String, Supplier> supls = new HashMap<>();
supls.put("transmission", new Supplier("ABC Precision Instruments"));
a.setSuppliers(supls);
kSession.insert(a);
System.out.println("***** start");
kSession.fireAllRules(10);
System.out.println("***** end");
$supplierName value will not be "ABC Precision Instruments" (the name property of Supplier object) but "A180" (the name property of Car object) unexpectedly.
$ mvn clean compile exec:exec -DgenerateModel=YES
...
***** Action of rule1a3
***** $car: com.example.reproducer.Car@4b6690c0, transmission supplier name = A180
...
Environment
- Red Hat Decision Manager (RHDM)
- 7.1.0 - 7.9.1
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.