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

Exception thrown when retract, reassert and retract again

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 3.0.1, 3.0.4
    • Fix Version/s: 3.0.5
    • Component/s: None
    • Labels:
      None

      Description

      In one rule retract the object and re-assert it, then retract the object again in the following activated rule. A null pointer exception will occur at this time.

      java.lang.NullPointerException
      at org.drools.reteoo.TerminalNode.retractTuple(TerminalNode.java:216)
      at org.drools.reteoo.LeftInputAdapterNode.retractObject(LeftInputAdapterNode.java:207)
      at org.drools.reteoo.ObjectSource.propagateRetractObject(ObjectSource.java:141)
      at org.drools.reteoo.ObjectTypeNode.retractObject(ObjectTypeNode.java:180)
      at org.drools.reteoo.Rete.retractObject(Rete.java:150)
      at org.drools.reteoo.ReteooRuleBase.retractObject(ReteooRuleBase.java:207)
      at org.drools.reteoo.ReteooWorkingMemory.doRetract(ReteooWorkingMemory.java:77)
      at org.drools.common.AbstractWorkingMemory.retractObject(AbstractWorkingMemory.java:668)
      at org.drools.base.DefaultKnowledgeHelper.retractObject(DefaultKnowledgeHelper.java:86)
      at com.ericsson.ruletest.debug.Rule_test2_0.consequence(Rule_test2_0.java:8)
      at com.ericsson.ruletest.debug.Rule_test2_0ConsequenceInvoker.evaluate(Rule_test2_0ConsequenceInvoker.java:22)
      at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:437)
      at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:407)
      at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:269)
      at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:256)
      at com.ericsson.ruletest.TestDriver.main(TestDriver.java:26)

      The given test case is the the simplified from my production code.

      --------------- test.drl ------------------------

      package com.ericsson.ruletest.debug

      import com.ericsson.ruletest.Fact;

      rule "test1"
      salience 10
      no-loop true
      when
      input:Fact();
      then
      retract(input);
      assert(input);
      end;

      rule "test2"
      salience 0
      no-loop true
      when
      input:Fact();
      then
      retract(input);
      end;

        Gliffy Diagrams

          Attachments

          1. Fact.java
            0.3 kB
          2. test.drl
            0.3 kB
          3. TestDriver.java
            1 kB

            Activity

              People

              • Assignee:
                tirelli Edson Tirelli
                Reporter:
                leoliang Leo Liang
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: