Bug 1072462 - NOT conditional element is broken when used with subnetworks
Summary: NOT conditional element is broken when used with subnetworks
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss BRMS Platform 6
Classification: Retired
Component: BRE
Version: 6.0.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ER2
: 6.0.1
Assignee: Mario Fusco
QA Contact: Marek Winkler
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-03-04 15:53 UTC by Mario Fusco
Modified: 2014-08-06 19:58 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-08-06 19:58:47 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker DROOLS-444 0 Critical Resolved NOT conditional element is broken when used with subnetworks 2014-03-17 15:55:48 UTC

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.


Note You need to log in before you can comment on or make changes to this bug.