Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-1032

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

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Duplicate Issue
    • Affects Version/s: 4.0.0.GA
    • Fix Version/s: 4.0.1
    • Component/s: None
    • Labels:
      None
    • Environment:

      Testing 4.0.0 on Windows XP, the released version.

      Description

      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)

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                tirelli Edson Tirelli
                Reporter:
                cwrm Andrew Harris
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: