Details
-
Bug
-
Resolution: Done
-
Major
-
5.4.0.CR1
-
None
Description
I have a rule with this element in the when clause:
$beforePrediction : Number() from accumulate( JobSlot(job != NULL_JOB, $j : job, $service == service, $ordinal > ordinal) and $p : Prediction(job == $j, service == $service), sum($p.getMillisMid()) )
When I execute this I have cases where there are no matching Prediction instances, so the sum is zero. Later on retract, I get this:
Caused by: java.lang.NullPointerException: null at org.drools.base.accumulators.SumAccumulateFunction.reverse(SumAccumulateFunction.java:83) at org.drools.base.accumulators.JavaAccumulatorFunctionExecutor.reverse(JavaAccumulatorFunctionExecutor.java:130) at org.drools.rule.Accumulate.reverse(Accumulate.java:208)
The relevant code is this:
public void accumulate(Serializable context, Object value) { SumData data = (SumData) context; data.total += ((Number) value).doubleValue(); }
and this:
public void reverse(Object workingMemoryContext, Object context, Tuple leftTuple, InternalFactHandle handle, Declaration[] declarations, Declaration[] innerDeclarations, WorkingMemory workingMemory) throws Exception { final Object value = ((JavaAccumulatorFunctionContext) context).reverseSupport.remove( Integer.valueOf( handle.getId() ) ); this.function.reverse( ((JavaAccumulatorFunctionContext) context).context, value ); }
A breakpoint reveals that handle is a Prediction instance. Somehow that handle was not added to reverseSupport, apparently.
Attachments
Issue Links
- relates to
-
JBRULES-3482 accumulate with an "and" predicate followed by an "or" causes a bogus ClassCast exception
- Resolved