Problem:
The application executes fireAllRules(), and during this process, it consistently throws the following NullPointerException:
java.lang.NullPointerException: Cannot invoke "org.drools.core.util.DoubleLinkedEntry.setPrevious(org.drools.core.util.DoubleLinkedEntry)" because "next" is null
at org.drools.core.util.LinkedList.removeAdd(LinkedList.java:275)
at org.drools.core.util.index.TupleList.removeAdd(TupleList.java:30)
at org.drools.core.phreak.RuleNetworkEvaluator.doUpdatesReorderRightMemory(RuleNetworkEvaluator.java:869)
at org.drools.core.phreak.PhreakAccumulateNode.doNode(PhreakAccumulateNode.java:77)
at org.drools.core.phreak.RuleNetworkEvaluator.switchOnDoBetaNode(RuleNetworkEvaluator.java:599)
at org.drools.core.phreak.RuleNetworkEvaluator.evalBetaNode(RuleNetworkEvaluator.java:566)
at org.drools.core.phreak.RuleNetworkEvaluator.evalNode(RuleNetworkEvaluator.java:393)
at org.drools.core.phreak.RuleNetworkEvaluator.innerEval(RuleNetworkEvaluator.java:353)
at org.drools.core.phreak.RuleNetworkEvaluator.evalStackEntry(RuleNetworkEvaluator.java:251)
at org.drools.core.phreak.RuleNetworkEvaluator.outerEval(RuleNetworkEvaluator.java:194)
at org.drools.core.phreak.RuleNetworkEvaluator.evaluateNetwork(RuleNetworkEvaluator.java:147)
at org.drools.core.phreak.RuleExecutor.evaluateNetwork(RuleExecutor.java:230)
at org.drools.kiesession.agenda.DefaultAgenda.evaluateEagerList(DefaultAgenda.java:503)
at org.drools.core.phreak.RuleExecutor.ruleWithHigherSalienceActivated(RuleExecutor.java:276)
at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:174)
at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:92)
at org.drools.core.concurrent.AbstractGroupEvaluator.evaluateAndFire(AbstractGroupEvaluator.java:48)
at org.drools.kiesession.agenda.DefaultAgenda.fireLoop(DefaultAgenda.java:620)
at org.drools.kiesession.agenda.DefaultAgenda.internalFireAllRules(DefaultAgenda.java:573)
at org.drools.kiesession.agenda.DefaultAgenda.fireAllRules(DefaultAgenda.java:565)
at org.drools.kiesession.session.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1093)
at org.drools.kiesession.session.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1084)
at org.drools.kiesession.session.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1068)
Context:
Questions:
Any pointers towards potential causes or further debugging strategies would be greatly appreciated!
Thanks for your time and expertise.
Nont
T previous = node.getPrevious();
T next = node.getNext();
if (previous == null) {
next.setPrevious( null );
this.firstNode = next;
} else {
previous.setNext( next );
next.setPrevious( previous );
}
--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/drools-usage/f8c98a53-b988-47a3-8ce6-14e21e2e5a2en%40googlegroups.com.
But then, there is still a kind of missing check, i.e. having next == null is an IllegalState (sort-of), so the code should intercept that situation and deal with it properly.
Instead, it currently relies on some "external" condition that, as this thread shows, may not be fullfilled.
Hi Mario, Gabriele,
Thank you both very much for the quick replies and the insightful discussion regarding the potential null check and the focus on the root cause.
Mario, following your suggestion, I have upgraded our project dependencies and tested specifically with Drools version 10.0.0
Unfortunately, the result is the same – we are still encountering the exact same NullPointerException with the identical stack trace originating from LinkedList.removeAdd / TupleList.removeAdd during PhreakAccumulateNode processing when fireAllRules() is called after switching agenda group focus.
Perhaps looking at a common pattern might help? Several rules in the agenda group where the error occurs use an accumulate pattern similar to this in their LHS:
$item_filter0 : List(size() >= N) from accumulate ( // N is typically 1 or 2
$filter: Item(productCode in ("someCode", "anotherCode")) from $cart.getExpandedItems(),
collectList($filter)
)
Thank you again for your time and expertise. Any further thoughts, however general, are appreciated.
Best regards,
To view this discussion visit https://groups.google.com/d/msgid/drools-usage/03e404ae-3cc9-49f8-bb47-9d46e87da5c9n%40googlegroups.com.
Hi Mario,
Following up on our discussion, I've created a minimal sample project that reproduces the NullPointerException. You can find it here: https://github.com/nontster/drools-sample.
Hopefully, this will give you the necessary context to investigate the issue further. Please let me know if you have any questions or need additional information.
Thanks, Nont