I have encountered the following issue when running a rule that has more than 1 collect from a same collection.
I have the following two rules:
rule "filter sentences based on existence of attributes"
when
IPhoneQueryCmd(State.POPULATE == state, $tidt: targetId)
$attributeFilteredSentences: ArrayList()
from collect (IPhoneSentences.Sentence(
( (descriptor.targetPrivatename == false) || (descriptor.targetPrivatename == $cmt.sentenceFilters.targetPrivatename) ) &&
( (descriptor.targetSurename == false) || (descriptor.targetSurename == $cmt.sentenceFilters.targetSurename) ) &&
( (descriptor.targetFullname == false) || (descriptor.targetFullname == $cmt.sentenceFilters.targetFullname) ) &&
( (descriptor.requesterPrivatename == false) || (descriptor.requesterPrivatename == $cmt.sentenceFilters.requesterPrivatename) ) &&
( (descriptor.requesterSurename == false) || (descriptor.requesterSurename == $cmt.sentenceFilters.requesterSurenamename) ) &&
( (descriptor.requesterFullname == false) || (descriptor.requesterFullname == $cmt.sentenceFilters.requesterFullname) ) &&
( (descriptor.time == false) || (descriptor.time == $cmt.sentenceFilters.time) ) &&
( (descriptor.subject == false) || (descriptor.subject == $cmt.subject) )
))
then
end
rule "Iphone targets information update - QUERY_AVAILABILITY" extends "filter sentences based on existence of attributes"
when
$qc: IPhoneQueryCmd(State.POPULATE == state, $tid: targetId)
$cm: ConditionMatrix($taskId: taskId,
targetId == $tid,
contextIntention == EContextIntention.QUERY_AVAILABILITY,
$timeConstraintType: requesterConstraint.constraintRequestType)
$targetResponse: ArrayList()
from collect (IPhoneSentences.Sentence(descriptor.intentions.intention contains EContextIntention.QUERY_AVAILABILITY.name)
from $attributeFilteredSentences)
then
//do something
End
This works fine but once I wish to add a second filtered ArrayList using $attributeFilteredSentences I get a null pointer exception.
For example I will add an exact similar filter condition but change the result var name (I called it $dummyVar)
rule "Iphone targets information update - QUERY_AVAILABILITY" extends "filter sentences based on existence of attributes"
when
$qc: IPhoneQueryCmd(State.POPULATE == state, $tid: targetId)
$cm: ConditionMatrix($taskId: taskId,
targetId == $tid,
contextIntention == EContextIntention.QUERY_AVAILABILITY,
$timeConstraintType: requesterConstraint.constraintRequestType)
$targetResponse: ArrayList()
from collect (IPhoneSentences.Sentence(descriptor.intentions.intention contains EContextIntention.QUERY_AVAILABILITY.name)
from $attributeFilteredSentences)
$dummyVar: ArrayList()
from collect (IPhoneSentences.Sentence(descriptor.intentions.intention contains EContextIntention.QUERY_AVAILABILITY.name)
from $attributeFilteredSentences)
then
//do something
End
In this case I get the following exception stack:
org.drools.runtime.rule.ConsequenceException: rule: Iphone dialog sentence - QUERY_AVAILABILITY
at org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:927)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:856)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1071)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:785)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:751)
at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)
at org.drools.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:302)
at com.delegatecom.task.TaskStatelessSession.testRunRules(TaskStatelessSession.java:122)
at com.delegatecom.task.TaskStatelessSession.internalTestNextStep(TaskStatelessSession.java:98)
at com.delegatecom.task.TaskStatelessSession.testNextStep(TaskStatelessSession.java:76)
at com.delegatecom.test.AtoB.testStatelessRule(AtoB.java:99)
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:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.NullPointerException
at org.drools.reteoo.AccumulateNode.getFirstMatch(AccumulateNode.java:967)
at org.drools.reteoo.AccumulateNode.splitList(AccumulateNode.java:920)
at org.drools.reteoo.AccumulateNode.removePreviousMatchesForLeftTuple(AccumulateNode.java:874)
at org.drools.reteoo.AccumulateNode.retractLeftTuple(AccumulateNode.java:205)
at org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateRetractLeftTuple(CompositeLeftTupleSinkAdapter.java:238)
at org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateRetractLeftTupleDestroyRightTuple(CompositeLeftTupleSinkAdapter.java:138)
at org.drools.reteoo.AccumulateNode.retractLeftTuple(AccumulateNode.java:212)
at org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateRetractLeftTuple(CompositeLeftTupleSinkAdapter.java:238)
at org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateRetractLeftTuple(CompositeLeftTupleSinkAdapter.java:122)
at org.drools.reteoo.JoinNode.retractLeftTuple(JoinNode.java:163)
at org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateRetractLeftTuple(SingleLeftTupleSinkAdapter.java:217)
at org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateRetractLeftTuple(SingleLeftTupleSinkAdapter.java:91)
at org.drools.reteoo.JoinNode.retractLeftTuple(JoinNode.java:163)
at org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateRetractLeftTuple(SingleLeftTupleSinkAdapter.java:217)
at org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateRetractLeftTupleDestroyRightTuple(SingleLeftTupleSinkAdapter.java:107)
at org.drools.reteoo.AccumulateNode.retractLeftTuple(AccumulateNode.java:212)
at org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateRetractLeftTuple(CompositeLeftTupleSinkAdapter.java:238)
at org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateRetractLeftTuple(CompositeLeftTupleSinkAdapter.java:122)
at org.drools.reteoo.JoinNode.retractLeftTuple(JoinNode.java:163)
at org.drools.reteoo.ModifyPreviousTuples.retractTuples(ModifyPreviousTuples.java:111)
at org.drools.reteoo.EntryPointNode.modifyObject(EntryPointNode.java:176)
at org.drools.common.AbstractWorkingMemory.update(AbstractWorkingMemory.java:1442)
at org.drools.common.AbstractWorkingMemory.update(AbstractWorkingMemory.java:1349)
at org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:183)
at org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:196)
at com.delegatecom.rules.drl.Rule_Iphone_dialog_sentence___QUERY_AVAILABILITY_0.defaultConsequence(Rule_Iphone_dialog_sentence___QUERY_AVAILABILITY_0.java:27)
at com.delegatecom.rules.drl.Rule_Iphone_dialog_sentence___QUERY_AVAILABILITY_0DefaultConsequenceInvoker.evaluate(Rule_Iphone_dialog_sentence___QUERY_AVAILABILITY_0DefaultConsequenceInvoker.java:65)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:917)
... 33 more
Any idea what this can be?
Regards,
Hezi