- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2.6k
Description
When multiple rules belonging to the same activation group are activated repeatedly by fact changes, only the first activation fires the cancellation of other activations in the activation-group. Subsequent activations result in the firing of ALL activated rules in the activation group. None are cancelled.
A simple ruleset that demonstrates this behavior is as follows.
package com.example
            
import StringFact;
            
rule "First rule in first activation group"
    activation-group "first-group"
    salience 10
when
    $strf : StringFact(value == "force", count < 5)
then
end
rule "Second rule in first activation group"
    activation-group "first-group"
    salience 5
when
    $strf : StringFact(value == "force", count < 5)
then
    modify($strf) { setValue("fail") }
end
rule "Rule without activation group"
    salience 2
when
    $strf : StringFact(value == "force", count < 1)
then
    modify($strf) { incrementCount() }
end
The second rule should never fire as long as the first rule has also been activated.
This test fails in the 7.x branch as well as the main branch.
I tracked down the issue to differences in PhreakRuleTerminalNode.doLeftTupleInsert(...) vs PhreakRuleTerminalNode.doLeftTupleUpdate(...). The insert method calls activationsManager.addItemToActivationGroup( leftTuple ) but the update method does not. Adding this call to the update methods allows the test to succeed.
See attached test class for the Drools::Model::Codegen module and PhreakRuleTerminalNode.java with suggested fix. This is my first time looking at this code base so "fix" needs to be evaluated for correctness.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status