Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluate property reactive "firstProp" in calculateMaskFromExpression #6092

Open
tkobayas opened this issue Sep 19, 2024 · 0 comments
Open
Assignees

Comments

@tkobayas
Copy link
Contributor

https://kie.zulipchat.com/#narrow/stream/232677-drools/topic/Static.20method.20in.20LHS

rule "cycle"
    when
        o1 : Object1( !Objects.isNull(field1) )
    then
        modify( o1 ) {
            setField2( "U" )
        }
end

With drools 8.44.0.Final, this rule causes a infinite loop, because in MVELConstraint.calculateMaskFromExpression, if firstProp (in this case, Objects) is not resolved as a fact's property, it results in allSetBitMask.

However, if we use static import,

import static java.util.Objects.isNull;

rule "cycle"
    when
        o1 : Object1( !isNull(field1) )
    then
        System.out.println("Rule cycle fired");
        modify( o1 ) {
            setField2( "U" )
        }
end

we can work around the problem and make it property reactive for only field1. (Method call arguments are reactive since 7.46.0 : https://docs.drools.org/7.73.0.Final/drools-docs/html_single/#better-property-reactivity )

Do we need such firstProp restriction? Consider use cases which requires firstProp and backward compatibility impact. Maybe we can check all props and then use allSetBitMask only when there is no valid prop.

Of course, also consider the consistency with exec-model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant