Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-629

NullPointerException thrown on next call to insert and fireAllRules after stream garbage collection runs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 6.2.0.CR1
    • 6.1.0.Final, 6.2.0.Beta3
    • None
    • None

      I have observed that the following NullPointerException (NPE) occurs consistently with a very specific set of rules and a very specific set of inputs into a stream session:

      java.lang.NullPointerException
          at org.drools.core.util.AbstractHashTable$SingleIndex.equal(AbstractHashTable.java:491)
          at org.drools.core.util.index.LeftTupleList.matches(LeftTupleList.java:266)
          at org.drools.core.util.index.LeftTupleIndexHashTable.get(LeftTupleIndexHashTable.java:434)
          at org.drools.core.util.index.LeftTupleIndexHashTable.getFirst(LeftTupleIndexHashTable.java:217)
          at org.drools.core.reteoo.BetaNode.getFirstLeftTuple(BetaNode.java:443)
          at org.drools.core.phreak.PhreakJoinNode.doRightInserts(PhreakJoinNode.java:144)
          at org.drools.core.phreak.PhreakJoinNode.doNode(PhreakJoinNode.java:56)
          at org.drools.core.phreak.RuleNetworkEvaluator.switchOnDoBetaNode(RuleNetworkEvaluator.java:548)
          at org.drools.core.phreak.RuleNetworkEvaluator.evalBetaNode(RuleNetworkEvaluator.java:534)
          at org.drools.core.phreak.RuleNetworkEvaluator.innerEval(RuleNetworkEvaluator.java:334)
          at org.drools.core.phreak.RuleNetworkEvaluator.outerEval(RuleNetworkEvaluator.java:161)
          at org.drools.core.phreak.RuleNetworkEvaluator.evaluateNetwork(RuleNetworkEvaluator.java:116)
          at org.drools.core.phreak.RuleExecutor.reEvaluateNetwork(RuleExecutor.java:229)
          at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:98)
          at org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:988)
          at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1274)
          at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1281)
          at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1254)
          ...
      

      The exception always occurs on the next call to "insert" and "fireAllRules" after the following method is invoked within the session: org.drools.core.common.DefaultAgenda$DefaultGarbageCollector.forceGcUnlinkedRules().

      I have attached a maven project that contains a JUnit test, which reproduces this exception using Drools version 6.2.0.Beta3.

      A side effect of this exeption occurring in the middle of fireAllRules is that an extra fact is left over in working memory, which is essentially a memory leak. I assume this is because the evaluation of the LHS of the rules is what causes the NPE to occur, so the fact is not deleted, because the RHS of the rules don't execute.

              mfusco@redhat.com Mario Fusco
              mikedev9000 Mike Wilson (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: