[
https://issues.jboss.org/browse/JBRULES-3466?page=com.atlassian.jira.plug...
]
Chris Dolan commented on JBRULES-3466:
--------------------------------------
It looks like the NPE is an symptom of corrupted working memory rather than a cause. When
I turned on TRACE (which I should have thought to do right away...) I get this:
{noformat}
java.lang.IllegalStateException: Score corruption: the workingScore (0hard/-25200soft) is
not the uncorruptedScore (0hard/-27600soft):
The workingMemory has 0 ConstraintOccurrence(s) lacking:
jobDelay/NEGATIVE_SOFT:[JobStart(JobSlot(s2,4),Job(j5),2400000)]=2400
Check the score rules who created those ConstraintOccurrences. Verify that each
ConstraintOccurrence's causes and weight is correct.
{noformat}
I have some work to do to understand this error, but at least now I know why my unit test
passed and my real-world problem fails.
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:
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see:
http://www.atlassian.com/software/jira