[jboss-jira] [JBoss JIRA] Commented: (JBRULES-1091) NullPointerException when the 'result' block of an 'accumulate' function returns null
Alexandre Gattiker (JIRA)
jira-events at lists.jboss.org
Wed Aug 22 16:20:18 EDT 2007
[ http://jira.jboss.com/jira/browse/JBRULES-1091?page=comments#action_12373396 ]
Alexandre Gattiker commented on JBRULES-1091:
---------------------------------------------
The intent of the actual business rule that spawned the bug was to use Drools to perform aggregation, in a similar way to a SQL query. Something like
when
$c:Customer()
$totalPayments:Money()
from accumulate( Payment ( customer == $c) ...
then
...do something with $totalPayments...
The result can be null. Obviously, using Drools syntax rather than collecting Payments in the RHS is mostly a convenience (though it might bring a performance boost in some cases).
The bug can be resolved easily by handling the null value in the hashCode call in DefaultFactHandle. But I assume that you worry about the case when constraints are placed on the accumulated value.
> NullPointerException when the 'result' block of an 'accumulate' function returns null
> -------------------------------------------------------------------------------------
>
> Key: JBRULES-1091
> URL: http://jira.jboss.com/jira/browse/JBRULES-1091
> Project: JBoss Rules
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Affects Versions: 4.0.0.GA
> Reporter: Alexandre Gattiker
> Assigned To: Edson Tirelli
> Fix For: 4.0.1
>
>
> java.lang.NullPointerException
> at org.drools.common.DefaultFactHandle.<init>(DefaultFactHandle.java:73)
> at org.drools.reteoo.ReteooFactHandleFactory.newFactHandle(ReteooFactHandleFactory.java:34)
> at org.drools.common.AbstractFactHandleFactory.newFactHandle(AbstractFactHandleFactory.java:57)
> at org.drools.common.AbstractFactHandleFactory.newFactHandle(AbstractFactHandleFactory.java:48)
> at org.drools.reteoo.AccumulateNode.assertTuple(AccumulateNode.java:176)
> at org.drools.reteoo.SingleTupleSinkAdapter.createAndPropagateAssertTuple(SingleTupleSinkAdapter.java:55)
> at org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:131)
> at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:20)
> at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:168)
> at org.drools.reteoo.Rete.assertObject(Rete.java:168)
> at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:190)
> at org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction.execute(ReteooWorkingMemory.java:163)
> at org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:1241)
> at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:858)
> at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:822)
> at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:623)
> at com.sample.DroolsTest.main(DroolsTest.java:28)
> Example rule:
> rule "Example"
> no-loop true
> when
> $d: Double()
> from accumulate ( m : Message( $value: status ),
> init( double total = 0; ),
> action( System.out.println($value); ),
> result( null )
> )
> then
> System.out.println( "xx");
>
> end
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list