Bug 809302 - NPE while creating activations if a fact is modified by prior consequences
NPE while creating activations if a fact is modified by prior consequences
Status: CLOSED CURRENTRELEASE
Product: JBoss Enterprise BRMS Platform 5
Classification: JBoss
Component: BRE (Expert, Fusion) (Show other bugs)
BRMS 5.2.0.GA
Unspecified Unspecified
unspecified Severity urgent
: ---
: One Off Releases
Assigned To: Lukáš Petrovický
Radovan Synek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-04-03 00:03 EDT by Alessandro Lazarotti
Modified: 2012-05-10 15:33 EDT (History)
11 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
PATCH NAME: Bug 809302 - One off patch Built upon previous roll up patch BZ-787847 PRODUCT NAME: JBoss Enterprise BRMS VERSION: 5.2.0 SHORT DESCRIPTION: NPE while creating activations if a fact is modified by prior consequences LONG DESCRIPTION: A NPE in terminal nodes can be raised if a same fact is updated in different agenda/rulefow groups MANUAL INSTALL INSTRUCTIONS: To install this patch replace the following with the jar from BZ809302.zip For BRMS Manager: $JBOSS_HOME/jboss-as/server/$PROFILE/jboss-brms.war/WEB-INF/lib/drools-core-5.2.0.BRMS.jar For BRMS Engine: The drools-core-5.2.0.BRMS.jar included with your application. COMPATIBILITY: DEPENDENCIES: N/A SUPERSEDES: N/A SUPERSEDED BY: N/A CREATOR: Neil Wallace DATE: April 10th 2012
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-04-25 06:03:28 EDT
Type: Support Patch
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Test case (9.36 KB, application/zip)
2012-04-03 00:17 EDT, Alessandro Lazarotti
no flags Details
patch (112 bytes, patch)
2012-04-03 00:20 EDT, Alessandro Lazarotti
no flags Details | Diff
Patch jar (1.84 MB, application/zip)
2012-04-24 12:23 EDT, Rick Wagner
no flags Details


External Trackers
Tracker ID Priority Status Summary Last Updated
JBoss Issue Tracker JBRULES-3234 Critical Closed NPE on modify when using lock-on-active after assert 2014-04-16 09:55:23 EDT

  None (edit)
Description Alessandro Lazarotti 2012-04-03 00:03:50 EDT
Description of problem:
A NPE in terminal nodes can be raised if a same fact is updated in different agenda/rulefow groups

Version-Release number of selected component (if applicable):
BRE from JBoss Enterprise BRMS 5.2

How reproducible:


Steps to Reproduce:
1.Unzip the attached file 
2.Import the project in JBDS
3.Run the class com.fraud.rule.test.TestDroolsBug.java
  
Actual results:
running
021 firing
042B firing
022 firing
Exception in thread "main" org.drools.runtime.rule.ConsequenceException: rule: Rule 022 - Load Buyer Activity

	at org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
	at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1101)
	at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1029)
	at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1251)
	at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:737)
	at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:701)
	at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)
	at com.fraud.rule.test.TestDroolsBug.main(TestDroolsBug.java:28)
Caused by: java.lang.NullPointerException
	at org.drools.reteoo.RuleTerminalNode.createActivations(RuleTerminalNode.java:276)
	at org.drools.reteoo.RuleTerminalNode.modifyLeftTuple(RuleTerminalNode.java:326)
	at org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateModifyChildLeftTuple(SingleLeftTupleSinkAdapter.java:273)

Expected results:
running
021 firing
042B firing
022 firing
done

Additional info:
Comment 1 Alessandro Lazarotti 2012-04-03 00:17:48 EDT
Created attachment 574727 [details]
Test case
Comment 2 Alessandro Lazarotti 2012-04-03 00:20:51 EDT
Created attachment 574728 [details]
patch

A simple patch checking the null value
Comment 3 Alessandro Lazarotti 2012-04-03 00:36:39 EDT
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
PRODUCT NAME:
        JBoss Enterprise BRMS
VERSION:
        5.2.0
SHORT DESCRIPTION:
       NPE while creating activations if a fact is modified by prior consequences
LONG DESCRIPTION:
       A NPE in terminal nodes can be raised if a same fact is updated in different agenda/rulefow groups
MANUAL INSTALL INSTRUCTIONS:
       To install this patch replace the following with the jars included in this patch:
       For BRMS Manager :
         $JBOSS_HOME/jboss-as/server/$PROFILE/jboss-brms.war/WEB-INF/lib/drools-core-5.2.0.BRMS.jar
       For BRMS Engine :
         The drools-core-5.2.0.BRMS.jar included with your application.
COMPATIBILITY:
 
DEPENDENCIES:
       N/A
SUPERSEDES:
       N/A
SUPERSEDED BY:
       N/A
CREATOR:
        Alessandro Lazarotti
DATE:
        04/03/2012
Comment 4 Alessandro Lazarotti 2012-04-03 00:39:05 EDT
In the last activation, the tuple.getObject() is null at RuleTerminalNode.createActivations, so we have the NPE. It happens for Drools 5.3+ and BRMS 5.2+ (before these versions the algorithm had used the method "modifyLeftTuple" with a different implementation instead of createActivations).

Using a null checker in createActivation (look the my proposed patch attached) fixes this issue and the test attached in JBRULES-3234 works as expected. I've sent to customer a hotfix (temporary) using this fix and his code is working as well. However a better solution is check with Edson if tuple.getObject() should really be null in that point or not, maybe something wrong is happen in the new nodes that implements LeftTuple.

Customer is waiting an official patch for this issue ASAP.
Comment 5 Alessandro Lazarotti 2012-04-03 00:39:05 EDT
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -8,10 +8,8 @@
        A NPE in terminal nodes can be raised if a same fact is updated in different agenda/rulefow groups
 MANUAL INSTALL INSTRUCTIONS:
        To install this patch replace the following with the jars included in this patch:
-       For BRMS Manager :
-         $JBOSS_HOME/jboss-as/server/$PROFILE/jboss-brms.war/WEB-INF/lib/drools-core-5.2.0.BRMS.jar
-       For BRMS Engine :
-         The drools-core-5.2.0.BRMS.jar included with your application.
+       For BRMS Manager: $JBOSS_HOME/jboss-as/server/$PROFILE/jboss-brms.war/WEB-INF/lib/drools-core-5.2.0.BRMS.jar
+       For BRMS Engine: The drools-core-5.2.0.BRMS.jar included with your application.
 COMPATIBILITY:
  
 DEPENDENCIES:
Comment 6 JBoss JIRA Server 2012-04-04 08:32:25 EDT
Mark Proctor <mark.proctor@jboss.com> made a comment on jira JBRULES-3234

The assert would get blocked, due to lock on active. So we'd have a fully matched rule with no AgendaItem. The later modify would expect there to be an AgendaItem as it's fully matched.

While i could have just done a null check, I changed this to just add a Boolean object if blocked and check for that. A null check is broader and might mask other issues.
Comment 7 JBoss JIRA Server 2012-04-04 08:32:52 EDT
Mark Proctor <mark.proctor@jboss.com> updated the status of jira JBRULES-3234 to Closed
Comment 8 Mark Proctor 2012-04-04 08:35:54 EDT
cherry-picked from 5.4 to 5.3.x:
commit 316806a57f426dfd8d86bb764921d6d0745bc26f
Author: Mark Proctor <mproctor@codehaus.org>
Date:   Wed Apr 4 12:12:42 2012 +0100

    JBRULES-3234 NPE on modify with lock-on-active
    (cherry picked from commit c6a3beea974234df599c4b3b80749f8ff15d3149)

    Conflicts:

        drools-compiler/src/test/java/org/drools/integrationtests/ExecutionFlowControlTest.java

commit f10be82a3e8ab62893afc7d5e6be7ffcd3262541
Comment 9 Edson Tirelli 2012-04-04 15:46:07 EDT
Fix backported into the 5.2.x branch as well.

https://github.com/droolsjbpm/drools/commit/7b86663a9d280060a8e1e778099e5e6c355240f8
Comment 10 Rick Wagner 2012-04-05 10:39:20 EDT
Productization, please build the '.jar' patch as described in email chain 'Re: Current patches need categorization, need inputs from QE and GSS (Alessandro)' from 04/05.

We know resources are stretched for Productization at this time, please keep us advised.  Thanks much for this effort, we know things are very busy!
Comment 11 nwallace 2012-04-10 19:52:07 EDT
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1,3 +1,6 @@
+PATCH NAME:
+        Bug 809302 - One off patch
+        Built upon previous roll up patch BZ-787847
 PRODUCT NAME:
         JBoss Enterprise BRMS
 VERSION:
@@ -6,8 +9,9 @@
        NPE while creating activations if a fact is modified by prior consequences
 LONG DESCRIPTION:
        A NPE in terminal nodes can be raised if a same fact is updated in different agenda/rulefow groups
+
 MANUAL INSTALL INSTRUCTIONS:
-       To install this patch replace the following with the jars included in this patch:
+       To install this patch replace the following with the jar from BZ809302.zip
        For BRMS Manager: $JBOSS_HOME/jboss-as/server/$PROFILE/jboss-brms.war/WEB-INF/lib/drools-core-5.2.0.BRMS.jar
        For BRMS Engine: The drools-core-5.2.0.BRMS.jar included with your application.
 COMPATIBILITY:
@@ -19,6 +23,6 @@
 SUPERSEDED BY:
        N/A
 CREATOR:
-        Alessandro Lazarotti
+        Neil Wallace
 DATE:
-        04/03/2012+        April 10th 2012
Comment 12 Radovan Synek 2012-04-12 08:52:48 EDT
The patch (BZ809302.zip) contains drools-core-5.2.1.BRMS.jar, but it should be drools-core-5.2.0.BRMS.jar
Comment 13 Radovan Synek 2012-04-12 11:03:47 EDT
There is even more serious problem - this is supposed to be one-off patch, but it seems like cumulative patch (more than 50 changed class files in drools-core since 5.2.0.GA)
Comment 14 Julian Coleman 2012-04-12 11:15:40 EDT
The patch was generated against the BRMS-P 5.2.0 roll up #1 (BZ-787847), which was
a cumulative patch.
Comment 15 Alessandro Lazarotti 2012-04-12 11:34:12 EDT
Please, it is necessary to check if the "MANUAL INSTALL INSTRUCTIONS" will work to customer just replacing his jars or can occur some java.lang.SecurityException like "signer information does not match signer information of other classes in the same package" since the jars are not in the same compiled version.

Tks
Comment 16 Radovan Synek 2012-04-13 03:39:04 EDT
(In reply to comment #14)
> The patch was generated against the BRMS-P 5.2.0 roll up #1 (BZ-787847), which
> was
> a cumulative patch.

There is still 7 changed class files compared to patch BZ-787847. That is more than I would expect from such a small fix.
Comment 17 Radovan Synek 2012-04-13 05:51:05 EDT
(In reply to comment #15)
> Please, it is necessary to check if the "MANUAL INSTALL INSTRUCTIONS" will work
> to customer just replacing his jars or can occur some
> java.lang.SecurityException like "signer information does not match signer
> information of other classes in the same package" since the jars are not in the
> same compiled version.
> 
> Tks

1) BRMS Manager
changing drools-core.jar seems to be without problems

2) BRMS Engine

I tried with JBDS and it depends where Drools Library came from - if it was created from JBDS, there is SecurityException because jars created by JBDS are unsigned. On the other hand, if Drools Library was created from brms-p-5.2.0.GA-deployable/jboss-brms-engine.zip, it works.
Comment 18 Alessandro Lazarotti 2012-04-13 09:39:28 EDT
(In reply to comment #16)
> (In reply to comment #14)
> > The patch was generated against the BRMS-P 5.2.0 roll up #1 (BZ-787847), which
> > was
> > a cumulative patch.
> 
> There is still 7 changed class files compared to patch BZ-787847. That is more
> than I would expect from such a small fix.

The real concept of "one-fix" or "single-fix" does not exist, all fixes are committed on a version of the same branch (in this case, 5.2.x
branch in github), so all fixes are now cumulative. This is different from what had occurred in the model JIRA/SVN which were separated branches to release one-off patches. Therefore you will see more changes than really used by this fix.
Comment 19 Radovan Synek 2012-04-16 04:16:22 EDT
(In reply to comment #18)
> (In reply to comment #16)
> > (In reply to comment #14)
> > > The patch was generated against the BRMS-P 5.2.0 roll up #1 (BZ-787847), which
> > > was
> > > a cumulative patch.
> > 
> > There is still 7 changed class files compared to patch BZ-787847. That is more
> > than I would expect from such a small fix.
> 
> The real concept of "one-fix" or "single-fix" does not exist, all fixes are
> committed on a version of the same branch (in this case, 5.2.x
> branch in github), so all fixes are now cumulative. This is different from what
> had occurred in the model JIRA/SVN which were separated branches to release
> one-off patches. Therefore you will see more changes than really used by this
> fix.

Ok, thank you for the explanation, so be it. But still, file name of jar with the fix should be drools-core-5.2.0.BRMS.jar instead of drools-core-5.2.1.BRMS.jar
Comment 20 Alessandro Lazarotti 2012-04-16 10:29:37 EDT
Hi team, customer is waiting this fix to migrate to production his application. When is the estimated date to release it?
Comment 21 Rick Wagner 2012-04-17 11:17:48 EDT
Jars have been renamed.  QE, could we please try again?  

Thanks,

Rick
Comment 22 Radovan Synek 2012-04-18 08:23:34 EDT
Patch is ready to be uploaded to customer portal.

Thanks
Comment 24 Rick Wagner 2012-04-24 12:23:32 EDT
Created attachment 579910 [details]
Patch jar
Comment 25 Rick Wagner 2012-04-24 12:24:21 EDT
MD5Sum for the attached fix .jar is 4a486cc98759a1456870e3c46fc7f678
Comment 26 Tushar Gandotra 2012-04-25 06:03:28 EDT
This patch is applicable to JBoss BRMS 5.2.0. It is available for download
from the following location:
https://access.redhat.com/jbossnetwork/restricted/softwareDetail.html?softwareId=11933

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