[rules-dev] Order of retraction matters
Wolfgang Laun
wolfgang.laun at gmail.com
Fri Feb 10 09:05:55 EST 2012
JBRULES-3383
Files attached to the JIRA represent a self-contained program, just javac
and java with a suitable classpath.
-W
On 10 February 2012 14:52, Edson Tirelli <ed.tirelli at gmail.com> wrote:
>
> Hi Wolfgang,
>
> Can you please open a JIRA for this.
>
> It seems the consequence is not properly managing the scope of $m.
> I.e., it must either cache it locally or queue the WMA until it executes
> completely.
>
> Thanks,
> Edson
>
> On Fri, Feb 10, 2012 at 6:52 AM, Wolfgang Laun <wolfgang.laun at gmail.com>wrote:
>
>> 5.3.0 Final.
>>
>> KnowledgeBase using STREAM, running a stateful session in one thread,
>> inserting events from another fact.
>>
>> class Event{ String name; }
>> class Monitor{ Event event; String name; }
>>
>> rule "start monitoring"
>> when
>> $e: Event($name: name)
>> not Monitor( name == $name )
>> then
>> insert( new Monitor( $e, $name ) );
>> end
>>
>> rule "timeout"
>> timer( int: 10s )
>> when
>> $m: Monitor( name == $name )
>> $e: Event($name: name)
>> then
>> retract( $m ); // =======================
>> retract( $m.getEvent() ); // ========================
>> end
>>
>> This order of retracts results in a NPE, see the dump below.
>>
>> Reversing these two works correctly.
>>
>> Exception in thread "main" Exception executing consequence for rule
>> "start monitoring" in hashcode: java.lang.NullPointerException
>> at
>> org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
>> at
>> org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1101)
>> at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1029)
>> at
>> org.drools.common.DefaultAgenda.fireUntilHalt(DefaultAgenda.java:1229)
>> at
>> org.drools.common.AbstractWorkingMemory.fireUntilHalt(AbstractWorkingMemory.java:753)
>> at
>> org.drools.common.AbstractWorkingMemory.fireUntilHalt(AbstractWorkingMemory.java:729)
>> at
>> org.drools.impl.StatefulKnowledgeSessionImpl.fireUntilHalt(StatefulKnowledgeSessionImpl.java:234)
>> at hashcode.Main.execute(Main.java:148)
>> at hashcode.Main.main(Main.java:206)
>> Caused by: java.lang.NullPointerException
>> at
>> org.drools.base.hashcode.StateEvent42211789$getItemName.getValue(Unknown
>> Source)
>> at org.drools.base.ClassFieldReader.getValue(ClassFieldReader.java:87)
>> at org.drools.rule.Declaration.getValue(Declaration.java:219)
>> at
>> hashcode.Rule_start_monitoringDefaultConsequenceInvoker.evaluate(Unknown
>> Source)
>> at
>> org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1091)
>> ... 7 more
>>
>>
>> _______________________________________________
>> rules-dev mailing list
>> rules-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-dev
>>
>>
>
>
> --
> Edson Tirelli
> JBoss Drools Core Development
> JBoss by Red Hat @ www.jboss.com
>
> _______________________________________________
> rules-dev mailing list
> rules-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20120210/f2e04568/attachment-0001.html
More information about the rules-dev
mailing list