Bug 999851

Summary: Using three or more identical rules with "forall" causes UnsupportedOperationException
Product: [Retired] JBoss BRMS Platform 6 Reporter: Petr Široký <psiroky>
Component: BREAssignee: Mario Fusco <mfusco>
Status: CLOSED CURRENTRELEASE QA Contact: Petr Široký <psiroky>
Severity: medium Docs Contact:
Priority: urgent    
Version: 6.0.0   
Target Milestone: ER5   
Target Release: 6.0.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-08-06 20:15:38 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Petr Široký 2013-08-22 09:24:33 UTC
Description of problem:
Using three or more identical rules (with just different name) that contain "forall" causes UnsupportedOperationException after calling fireAllRules(). It does not really makes sense to create identical rules, but I think the engine should cope with that and don't throw exception.

E.g:
rule "All objects are equal_1"
when
    forall ($obj : Object()
            Object(this == $obj)
    )
then
end

rule "All objects are equal_2"
when
    forall ($obj : Object()
            Object(this == $obj)
    )
then
end

rule "All objects are equal_3"
when
    forall ($obj : Object()
            Object(this == $obj)
    )
then
end


Full stracktrace:
java.lang.UnsupportedOperationException
  at org.drools.core.reteoo.BaseLeftTuple.getBlocker(BaseLeftTuple.java:532)
  at org.drools.core.phreak.PhreakNotNode.doLeftInserts(PhreakNotNode.java:102)
  at org.drools.core.phreak.PhreakNotNode.doNode(PhreakNotNode.java:69)
  at org.drools.core.phreak.RuleNetworkEvaluator.switchOnDoBetaNode(RuleNetworkEvaluator.java:553)
  at org.drools.core.phreak.RuleNetworkEvaluator.evalBetaNode(RuleNetworkEvaluator.java:530)
  at org.drools.core.phreak.RuleNetworkEvaluator.innerEval(RuleNetworkEvaluator.java:335)
  at org.drools.core.phreak.RuleNetworkEvaluator.evalStackEntry(RuleNetworkEvaluator.java:231)
  at org.drools.core.phreak.RuleNetworkEvaluator.outerEval(RuleNetworkEvaluator.java:167)
  at org.drools.core.phreak.RuleNetworkEvaluator.evaluateNetwork(RuleNetworkEvaluator.java:117)
  at org.drools.core.phreak.RuleExecutor.reEvaluateNetwork(RuleExecutor.java:205)
  at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:65)
  at org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:936)
  at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1183)
  at org.drools.core.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:928)
  at org.drools.core.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:902)
  at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:233)


Note that the exception is only thrown when there are three or more of these identical rules (I could not reproduce it with one or two) and also I have been able to reproduce it only when using "forall", but it is possible that it could be happening using also other constructs.

I will create PR with test reproducing the issue asap.


Version-Release number of selected component (if applicable):
6.0.0-ER1 (and community 6.1.0-SNAPSHOT, 6.0.0-SNAPSHOT)


How reproducible:
Always


Steps to Reproduce:
1. Build kbase from the above rules.
2. Create ksession and call fireAllRules()


Actual results:
UnsupportedOperationException.


Expected results:
Successful execution.

Comment 1 Petr Široký 2013-08-22 16:30:38 UTC
Created PR with test reproducing the issue: https://github.com/droolsjbpm/drools/pull/240

Comment 2 Mario Fusco 2013-10-03 16:43:53 UTC
This issue has been fixed by Mark with this commit: https://github.com/droolsjbpm/drools/commit/eca450ead

I pushed a test case demonstrating that it is working now: https://github.com/droolsjbpm/drools/commit/116bee5bf

Comment 6 Petr Široký 2013-11-25 13:07:39 UTC
Verified fixed in 6.0.0-ER5.