apache / incubator-kie-drools

Drools is a rule engine, DMN engine and complex event processing (CEP) engine for Java.
http://www.drools.org
Apache License 2.0
5.88k stars 2.5k forks source link

executable model fails to handle property reactive with null-safe-dereferencing #5957

Closed tkobayas closed 5 months ago

tkobayas commented 6 months ago

When using null-safe-dereferencing !., exec-model fails to handle property reactive, so works like class reactive.

rule R 
when
    $p: Person(address!.street == "street1")
then
    modify($p) { setLikes("Cheese") };
end

This rule causes a loop.

tkobayas commented 6 months ago

Workaround: Change (address!.street == "street1") to (address != null, address.street == "street1")

Note: Ensure that ExpressionTyperContext.addReactOnProperties for the prop is called in https://github.com/apache/incubator-kie-drools/blob/main/drools-model/drools-model-codegen/src/main/java/org/drools/model/codegen/execmodel/generator/visitor/pattern/ClassPatternDSL.java#L276-L280

tkobayas commented 5 months ago

Fixed by https://github.com/apache/incubator-kie-drools/pull/5963