[
https://issues.jboss.org/browse/JBRULES-3293?page=com.atlassian.jira.plug...
]
Pavel Kudryashov updated JBRULES-3293:
--------------------------------------
Description:
If try to create ArrayList by collect with size restriction and then execute accumulate on
it, environment fails. If remove ArrayList size restriction or don't use accumulate,
everything works fine.
Here is the example code.
==================================================
rule "Large transaction"
when
//select last 3 transaction
$lastTransactions : ArrayList(size == 3) from collect(TransactionCompleted() over
window:length(3))
//calculate average sum
accumulate(TransactionCompleted($amount : amount) from $lastTransactions,
$averageAmount : average($amount))
//find large transactions
$largeTransaction : TransactionCompleted(amount > 2 * $averageAmount) over
window:length(1)
then
situationsReporter.report("Large transaction");
end
==================================================
If rewrite the code the other way it works fine:
==================================================
rule "Large transaction"
when
//select last 3 transaction
$lastTransactions : ArrayList() from collect(TransactionCompleted() over
window:length(3))
//calculate average sum
accumulate(TransactionCompleted($amount : amount) from $lastTransactions,
$averageAmount : average($amount))
//check if we have exactly 3 transactions
eval($lastTransactions.size() == 3)
//find large transactions
$largeTransaction : TransactionCompleted(amount > 2 * $averageAmount) over
window:length(1)
then
situationsReporter.report("Large transaction");
end
==================================================
But if in the latter piece of code move eval($lastTransactions.size() == 3) above
accumulate() it will fail the same as the first piece of code:
==================================================
Exception in thread "Thread-4" org.drools.runtime.rule.ConsequenceException:
rule: Transaction completed
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1093)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1022)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1243)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:733)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:699)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)
at org.siemens.reaf.reasoning.cep.DroolsEngine.processEvents(DroolsEngine.java:393)
at
org.siemens.reaf.reasoning.cep.SensorEventsProcessor$ProcessingWorker.run(SensorEventsProcessor.java:36)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at
org.drools.reteoo.ReteooWorkingMemory$EvaluateResultConstraints.execute(ReteooWorkingMemory.java:576)
at
org.drools.common.PropagationContextImpl.evaluateActionQueue(PropagationContextImpl.java:265)
at org.drools.rule.SlidingLengthWindow.assertRightTuple(SlidingLengthWindow.java:114)
at org.drools.rule.BehaviorManager.assertRightTuple(BehaviorManager.java:84)
at org.drools.reteoo.AccumulateNode.assertObject(AccumulateNode.java:247)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:379)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:134)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:204)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:241)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:332)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:293)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:905)
at org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:180)
at org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:174)
at
org.siemens.reaf.reasoning.cep.Rule_Transaction_completed_0.defaultConsequence(Rule_Transaction_completed_0.java:9)
at
org.siemens.reaf.reasoning.cep.Rule_Transaction_completed_0DefaultConsequenceInvoker.evaluate(Rule_Transaction
completed_0DefaultConsequenceInvoker.java:36)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1083)
... 8 more
==================================================
Although I may be wrong with the first piece of code, I think it shouldn't fail in the
second if eval() and transaction() parts are just swapped around.
Thank you.
was:
If try to create ArrayList by collect with size restriction and then execute accumulate on
it, environment fails. If remove ArrayList size restriction or don't use accumulate,
everything works fine.
Here is the example code.
==================================================
rule "Large transaction"
when
//select last 3 transaction
$lastTransactions : ArrayList(size == 3) from collect(TransactionCompleted() over
window:length(3))
//calculate average sum
accumulate(TransactionCompleted($amount : amount) from $lastTransactions,
$averageAmount : average($amount))
//find large transactions
$largeTransaction : TransactionCompleted(amount > 2 * $averageAmount) over
window:length(1)
then
situationsReporter.report("Large transaction");
end
==================================================
If rewrite the code the other way it works fine:
==================================================
rule "Large transaction"
when
//select last 3 transaction
$lastTransactions : ArrayList() from collect(TransactionCompleted() over
window:length(3))
//calculate average sum
accumulate(TransactionCompleted($amount : amount) from $lastTransactions,
$averageAmount : average($amount))
//check if we have exactly 3 transactions
eval($lastTransactions.size() == 3)
//find large transactions
$largeTransaction : TransactionCompleted(amount > 2 * $averageAmount) over
window:length(1)
then
situationsReporter.report("Large transaction");
end
==================================================
But if in the latter piece of code move eval($lastTransactions.size() == 3) above
accumulate() it will fail the same as the first piece of code:
==================================================
Exception in thread "Thread-4" org.drools.runtime.rule.ConsequenceException:
rule: Transaction completed
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1093)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1022)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1243)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:733)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:699)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)
at org.siemens.reaf.reasoning.cep.DroolsEngine.processEvents(DroolsEngine.java:393)
at
org.siemens.reaf.reasoning.cep.SensorEventsProcessor$ProcessingWorker.run(SensorEventsProcessor.java:36)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at
org.drools.reteoo.ReteooWorkingMemory$EvaluateResultConstraints.execute(ReteooWorkingMemory.java:576)
at
org.drools.common.PropagationContextImpl.evaluateActionQueue(PropagationContextImpl.java:265)
at org.drools.rule.SlidingLengthWindow.assertRightTuple(SlidingLengthWindow.java:114)
at org.drools.rule.BehaviorManager.assertRightTuple(BehaviorManager.java:84)
at org.drools.reteoo.AccumulateNode.assertObject(AccumulateNode.java:247)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:379)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:134)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:204)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:241)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:332)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:293)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:905)
at org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:180)
at org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:174)
at
org.siemens.reaf.reasoning.cep.Rule_Transaction_completed_0.defaultConsequence(Rule_Transaction_completed_0.java:9)
at
org.siemens.reaf.reasoning.cep.Rule_Transaction_completed_0DefaultConsequenceInvoker.evaluate(Rule_Transaction
completed_0DefaultConsequenceInvoker.java:36)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1083)
... 8 more
==================================================
Thank you.
Array size restriction causes collect/accumulute to fail
--------------------------------------------------------
Key: JBRULES-3293
URL:
https://issues.jboss.org/browse/JBRULES-3293
Project: Drools
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: drools-core
Affects Versions: 5.3.0.Beta1
Reporter: Pavel Kudryashov
Assignee: Mark Proctor
If try to create ArrayList by collect with size restriction and then execute accumulate
on it, environment fails. If remove ArrayList size restriction or don't use
accumulate, everything works fine.
Here is the example code.
==================================================
rule "Large transaction"
when
//select last 3 transaction
$lastTransactions : ArrayList(size == 3) from collect(TransactionCompleted() over
window:length(3))
//calculate average sum
accumulate(TransactionCompleted($amount : amount) from $lastTransactions,
$averageAmount : average($amount))
//find large transactions
$largeTransaction : TransactionCompleted(amount > 2 * $averageAmount) over
window:length(1)
then
situationsReporter.report("Large transaction");
end
==================================================
If rewrite the code the other way it works fine:
==================================================
rule "Large transaction"
when
//select last 3 transaction
$lastTransactions : ArrayList() from collect(TransactionCompleted() over
window:length(3))
//calculate average sum
accumulate(TransactionCompleted($amount : amount) from $lastTransactions,
$averageAmount : average($amount))
//check if we have exactly 3 transactions
eval($lastTransactions.size() == 3)
//find large transactions
$largeTransaction : TransactionCompleted(amount > 2 * $averageAmount) over
window:length(1)
then
situationsReporter.report("Large transaction");
end
==================================================
But if in the latter piece of code move eval($lastTransactions.size() == 3) above
accumulate() it will fail the same as the first piece of code:
==================================================
Exception in thread "Thread-4" org.drools.runtime.rule.ConsequenceException:
rule: Transaction completed
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1093)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1022)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1243)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:733)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:699)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)
at org.siemens.reaf.reasoning.cep.DroolsEngine.processEvents(DroolsEngine.java:393)
at
org.siemens.reaf.reasoning.cep.SensorEventsProcessor$ProcessingWorker.run(SensorEventsProcessor.java:36)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at
org.drools.reteoo.ReteooWorkingMemory$EvaluateResultConstraints.execute(ReteooWorkingMemory.java:576)
at
org.drools.common.PropagationContextImpl.evaluateActionQueue(PropagationContextImpl.java:265)
at org.drools.rule.SlidingLengthWindow.assertRightTuple(SlidingLengthWindow.java:114)
at org.drools.rule.BehaviorManager.assertRightTuple(BehaviorManager.java:84)
at org.drools.reteoo.AccumulateNode.assertObject(AccumulateNode.java:247)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:379)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:134)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:204)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:241)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:332)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:293)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:905)
at org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:180)
at org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:174)
at
org.siemens.reaf.reasoning.cep.Rule_Transaction_completed_0.defaultConsequence(Rule_Transaction_completed_0.java:9)
at
org.siemens.reaf.reasoning.cep.Rule_Transaction_completed_0DefaultConsequenceInvoker.evaluate(Rule_Transaction
completed_0DefaultConsequenceInvoker.java:36)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1083)
... 8 more
==================================================
Although I may be wrong with the first piece of code, I think it shouldn't fail in
the second if eval() and transaction() parts are just swapped around.
Thank you.
--
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