[jboss-jira] [JBoss JIRA] Created: (JBRULES-1032) NPE in HashKey.equals when LHS checks for null object, the object is null, and there are more than 3 rules

Andrew Harris (JIRA) jira-events at lists.jboss.org
Thu Jul 26 17:17:16 EDT 2007


NPE in HashKey.equals when LHS checks for null object, the object is null, and there are more than 3 rules
----------------------------------------------------------------------------------------------------------

                 Key: JBRULES-1032
                 URL: http://jira.jboss.com/jira/browse/JBRULES-1032
             Project: JBoss Rules
          Issue Type: Bug
      Security Level: Public (Everyone can see)
    Affects Versions:  4.0.0.GA
         Environment: Testing 4.0.0 on Windows XP, the released version.
            Reporter: Andrew Harris
         Assigned To: Mark Proctor
         Attachments: Hash Error Case.zip

I have a rule that checks for an object field being null as below

when
      m : Message( statusMessage == null )

When the field is null, and there are three or more rules in the rule file, then I get a NPE at 

org.drools.reteoo.CompositeObjectSinkAdapter$HashKey.equals(CompositeObjectSinkAdapter.java:608)

This line is 

                   return (this.index == other.index) && (this.ovalue.equals( otherValue ));

and ovalue.equals is null, causing the NullPointerException.  

This only happens if there are 3 or more rules, because the default configuration says that the HASH_THRESHOLD_SYSTEM_PROPERTY is 3.

The full stack trace is below, and I have attached a simple test case.  Note that the test case was originally tested in 3.0.6 and works fine there.

java.lang.NullPointerException
	at org.drools.reteoo.CompositeObjectSinkAdapter$HashKey.equals(CompositeObjectSinkAdapter.java:608)
	at org.drools.util.AbstractHashTable$EqualityEquals.equal(AbstractHashTable.java:345)
	at org.drools.util.ObjectHashMap.get(ObjectHashMap.java:86)
	at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:295)
	at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:168)
	at org.drools.reteoo.Rete.assertObject(Rete.java:168)
	at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:190)
	at org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:70)
	at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:848)
	at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:822)
	at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:623)
	at com.sample.DroolsTest.runTest(Unknown Source)
	at com.sample.DroolsTest.testRules(Unknown Source)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at junit.framework.TestCase.runTest(TestCase.java:154)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:421)
	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:912)
	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:766)


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list