]
Edson Tirelli resolved JBRULES-3466.
------------------------------------
Fix Version/s: 5.4.0.Final
5.5.0.Beta1
Resolution: Done
Thank you for reporting, providing test case and helping on the analysis. It is fixed
now.
accumulate with an "and" condition results in NPE on
reverse
------------------------------------------------------------
Key: JBRULES-3466
URL:
https://issues.jboss.org/browse/JBRULES-3466
Project: Drools
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: drools-core (expert)
Affects Versions: 5.4.0.CR1
Environment: drools-planner 5.4.0-SNAPSHOT, snapshot downloaded on Apr 9, 2012
Reporter: Chris Dolan
Assignee: Edson Tirelli
Fix For: 5.4.0.Final, 5.5.0.Beta1
I have a rule with this element in the when clause:
{noformat}
$beforePrediction : Number() from accumulate(
JobSlot(job != NULL_JOB, $j : job, $service == service, $ordinal >
ordinal) and $p : Prediction(job == $j, service == $service),
sum($p.getMillisMid())
)
{noformat}
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:
{noformat}
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)
{noformat}
The relevant code is this:
{noformat}
public void accumulate(Serializable context,
Object value) {
SumData data = (SumData) context;
data.total += ((Number) value).doubleValue();
}
{noformat}
and this:
{noformat}
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 );
}
{noformat}
A breakpoint reveals that handle is a Prediction instance. Somehow that handle was not
added to reverseSupport, apparently.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: