Bugzilla (bugzilla.redhat.com) will be under maintenance for infrastructure upgrades and will not be unavailable on July 31st between 12:30 AM - 05:30 AM UTC. We appreciate your understanding and patience. You can follow status.redhat.com for details.
Bug 809302 - NPE while creating activations if a fact is modified by prior consequences
Summary: NPE while creating activations if a fact is modified by prior consequences
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Enterprise BRMS Platform 5
Classification: JBoss
Component: BRE (Expert, Fusion)
Version: BRMS 5.2.0.GA
Hardware: Unspecified
OS: Unspecified
unspecified
urgent
Target Milestone: ---
: One Off Releases
Assignee: Lukáš Petrovický
QA Contact: Radovan Synek
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-04-03 04:03 UTC by Alessandro Lazarotti
Modified: 2018-11-27 20:17 UTC (History)
11 users (show)

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
Clone Of:
Environment:
Last Closed: 2012-04-25 10:03:28 UTC
Type: Support Patch


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


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker JBRULES-3234 0 Critical Closed NPE on modify when using lock-on-active after assert 2014-04-16 13:55:23 UTC

Description Alessandro Lazarotti 2012-04-03 04:03:50 UTC
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 04:17:48 UTC
Created attachment 574727 [details]
Test case

Comment 2 Alessandro Lazarotti 2012-04-03 04:20:51 UTC
Created attachment 574728 [details]
patch

A simple patch checking the null value

Comment 3 Alessandro Lazarotti 2012-04-03 04:36:39 UTC
    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 04:39:05 UTC
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 04:39:05 UTC
    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 12:32:25 UTC
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 12:32:52 UTC
Mark Proctor <mark.proctor@jboss.com> updated the status of jira JBRULES-3234 to Closed

Comment 8 Mark Proctor 2012-04-04 12:35:54 UTC
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 19:46:07 UTC
Fix backported into the 5.2.x branch as well.

https://github.com/droolsjbpm/drools/commit/7b86663a9d280060a8e1e778099e5e6c355240f8

Comment 10 Rick Wagner 2012-04-05 14:39:20 UTC
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 23:52:07 UTC
    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 12:52:48 UTC
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 15:03:47 UTC
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 15:15:40 UTC
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 15:34:12 UTC
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 07:39:04 UTC
(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 09:51:05 UTC
(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 13:39:28 UTC
(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 08:16:22 UTC
(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 14:29:37 UTC
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 15:17:48 UTC
Jars have been renamed.  QE, could we please try again?  

Thanks,

Rick

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

Thanks

Comment 24 Rick Wagner 2012-04-24 16:23:32 UTC
Created attachment 579910 [details]
Patch jar

Comment 25 Rick Wagner 2012-04-24 16:24:21 UTC
MD5Sum for the attached fix .jar is 4a486cc98759a1456870e3c46fc7f678

Comment 26 Tushar Gandotra 2012-04-25 10:03:28 UTC
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.