]
Chris Dolan commented on JBRULES-3466:
--------------------------------------
Ahh, of course it's Expert not Planner. I should have realized that...
I'm looking at MiscTest. I'm not confident that I can write a test for this, but
I'll give it a try.
One more probably-important point I forgot to mention (sorry!): my Prediction facts are
injected into the working memory via insertLogical() from a higher salience rule. So, the
retraction of the Prediction derives from the undo of that other rule, I believe.
sum with no matching values 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
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: