Bug 1072462

Summary: NOT conditional element is broken when used with subnetworks
Product: [Retired] JBoss BRMS Platform 6 Reporter: Mario Fusco <mfusco>
Component: BREAssignee: Mario Fusco <mfusco>
Status: CLOSED CURRENTRELEASE QA Contact: Marek Winkler <mwinkler>
Severity: high Docs Contact:
Priority: high    
Version: 6.0.0CC: etirelli, mbaluch, rrajasek, rzhang
Target Milestone: ER2   
Target Release: 6.0.1   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-08-06 19:58:47 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:
Embargoed:

Description Mario Fusco 2014-03-04 15:53:12 UTC
In some cases, when a NOT node is the root of a subnetwork, the phreak segment having that node as root is not initialized as expected when the initial fact is inserted. That can prevent a rule to fire even if it should as demonstrated by the following test case.

    @Test
    public void testNestedNots() {
        String str = "package org.test; " +

                     "rule negation_distributed_partially_no_sharing " +
                     "when " +
                     " (not String()) " +
                     " and " +
                     " (not (Double() and Integer())) " +
                     "then " +
                     " System.out.println(\"firing\"); " +
                     "end";

        KnowledgeBase kbase = loadKnowledgeBaseFromString(str);
        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

        int n = ksession.fireAllRules();

        assertEquals(1, n);
    }

Note that if you invert the 2 NOTs putting the one with 2 conditions before the other the test succeeds.

Comment 2 Mario Fusco 2014-03-04 16:27:09 UTC
Fixed by https://github.com/droolsjbpm/drools/commit/0faf0e32d

Comment 3 Edson Tirelli 2014-03-04 17:30:39 UTC
This was cherry-picked into the 6.0.1.ER2 tag:

https://github.com/jboss-integration/drools/commit/db551f6

Comment 4 JBoss JIRA Server 2014-03-05 13:35:29 UTC
Mario Fusco <mario.fusco> updated the status of jira DROOLS-444 to Resolved

Comment 5 Marek Winkler 2014-03-17 15:55:42 UTC
Verified that the fix is present in BRMS 6.0.1 ER2 and the relevant tests pass.