-
Bug
-
Resolution: Done
-
Major
-
None
-
None
Having a shared Query Node as last node of a segment causes a NPE as in the following test case
@Test public void testSharedQueryNode() throws Exception { String drl = "query find( Integer $i, String $s )\n" + " $i := Integer( toString() == $s )\n" + "end\n" + "\n" + "rule R2 salience -1 when\n" + " $s : String()\n" + " ?find( i, $s; )\n" + "then\n" + "end\n" + "rule R1 when\n" + " $s : String()\n" + " ?find( i, $s; )\n" + " $i : Integer( this == 1 ) from i\n" + "then\n" + " delete( $s );\n" + "end\n"; KieHelper helper = new KieHelper(); helper.addContent( drl, ResourceType.DRL ); KieSession ksession = helper.build().newKieSession(); ksession.insert("1"); ksession.insert(1); ksession.fireAllRules(); }
causes a NullPointerException like:
java.lang.NullPointerException
at org.drools.core.common.LeftTupleSetsImpl.removeInsert(LeftTupleSetsImpl.java:136)
at org.drools.core.phreak.RuleNetworkEvaluator.deleteLeftChild(RuleNetworkEvaluator.java:754)
at org.drools.core.phreak.PhreakQueryNode.doLeftDeletes(PhreakQueryNode.java:175)
at org.drools.core.phreak.PhreakQueryNode.doNode(PhreakQueryNode.java:31)
at org.drools.core.phreak.RuleNetworkEvaluator.evalQueryNode(RuleNetworkEvaluator.java:464)
at org.drools.core.phreak.RuleNetworkEvaluator.innerEval(RuleNetworkEvaluator.java:353)
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:216)
at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:91)
at org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:964)
at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1234)