[jboss-jira] [JBoss JIRA] (DROOLS-138) AccumulateNode throws NPE

Davide Sottara (JIRA) jira-events at lists.jboss.org
Tue May 14 15:39:06 EDT 2013


    [ https://issues.jboss.org/browse/DROOLS-138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12774298#comment-12774298 ] 

Davide Sottara commented on DROOLS-138:
---------------------------------------

This is a bug, but the rulebase itself raises some concerns

1) In your setup, you keep inserting facts in a LENGTH window: the engine is NOT queueing facts or using the window to synchronize the producer (the main thread) and the consumer 
(the rule execution thread), which means that it's extremely likely that you will lose some average updates. I'd think that this is partly a bug of your rulebase: you are "compressing" 
time to zero, having all your events inserted continuously "at the same time", which is unrealistic.

If the engine worked correctly, you would get a lossy behaviour. Unfortunately the race condition causes an exception, which is an ENGINE bug.

2) The "number rule" and "average temp" are out of synch. Since your threads are not synchronized, the "number rule" updates will be picked up at some point by the rule execution thread, which may be much later than when the "average temp" has been fired. This is a bug in your rule base.

3) The agenda, by default, fires rules in a LIFO mode. With your LENGTH window and insertion mode, the "average" activations will be queued and fired in the EXACTLY OPPOSITE order
than I assume you would expect. This needs more thought.

                
> AccumulateNode throws NPE
> -------------------------
>
>                 Key: DROOLS-138
>                 URL: https://issues.jboss.org/browse/DROOLS-138
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 5.5.1.Final
>         Environment: ### OS ###
> Darwin <hostname redacted> 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64
> ### Java Version ###
> java version "1.6.0_45"
> Java(TM) SE Runtime Environment (build 1.6.0_45-b06-451-11M4406)
> Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01-451, mixed mode)
>            Reporter: Jason Barto
>            Assignee: Mark Proctor
>            Priority: Minor
>
> AccumulateNode throws a NPE when events are inserted too quickly via an entry-point.  A stateful knowledge session to which events are inserted and running an accumulate on the input events.  I have a for loop generating the events and inserting them as rapidly as possible.  In the rules I use an accumulator to calculate the average of the values contained within the events.  The behavior I'm observing is that if I insert ~120 events without any waiting I receive an NPE.  If I Thread.sleep for even just 1ms the test goes off without a hitch.  
> The NPE is as follows:
> Exception in thread "main" java.lang.NullPointerException
>         at org.drools.reteoo.AccumulateNode.getFirstMatch(AccumulateNode.java:1050)
>         at org.drools.reteoo.AccumulateNode.modifyLeftTuple(AccumulateNode.java:345)
>         at org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateModifyChildLeftTuple(SingleLeftTupleSinkAdapter.java:259)
>         at org.drools.reteoo.AccumulateNode.evaluateResultConstraints(AccumulateNode.java:676)
>         at org.drools.reteoo.ReteooWorkingMemory$EvaluateResultConstraints.execute(ReteooWorkingMemory.java:590)
>         at org.drools.common.PropagationContextImpl.evaluateActionQueue(PropagationContextImpl.java:350)
>         at org.drools.rule.SlidingLengthWindow.assertFact(SlidingLengthWindow.java:119)
>         at org.drools.rule.BehaviorManager.assertFact(BehaviorManager.java:94)
>         at org.drools.reteoo.WindowNode.assertObject(WindowNode.java:167)
>         at org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497)
>         at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382)
>         at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
>         at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
>         at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:350)
>         at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:311)
>         at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:127)
>         at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:55)
>         at drools5fusioneval.Average.main(Average.java:66)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list