I am running 2 rules that are very similar but with a slight change:
rule One
when
$foo : Foo($name : Name, $msg : Message !="")
$prev : ArrayList(size<1) from collect( Foo(Name==$name, Message == $msg,
this before $foo)
$list : Set(size>0) from accumulate( Foo(Name == $name, $msgs: Message !=
$msg, this after $foo), collectSet($msgs))
then
System.out.println($name + "\twent from \"" + $msg + "\"\tto
" + $list);
end
rule Two
when
$foo : Foo($name : Name, $msg : Message !="")
Not( Foo(Name==$name, Message == $msg, this before $foo))
$list : Set(size>0) from accumulate( Foo(Name == $name, $msgs: Message !=
$msg, this after $foo), collectSet($msgs))
then
System.out.println($name + "\twent A from \"" + $msg + "\"\tto
" + $list);
end
rule One works just fine however its rule Two I seem to be having trouble
with. In my main method I have an initial print statement, then I go through
this whole process of parsing XML files into objects and then adding those
objects into the session. Once all the objects are entered I do a print out,
I then call fireAllRules on the session and then do another print out.
When I use rule Two, my program starts firing the rules and displaying their
results almost immediately, even before the 2nd print out (sometimes even
before the first initial print out). Most of the time I get a Null Pointer
Exception but it does occasionally finish running. In the cases it does
finish it spits out the output from most of the rules then displays the 2nd
printout, the print out from a rule and then the ending print out. When it
does throw the null pointer exception I get:
java.lang.NullPointerException
at org.drools.core.util.LinkedList.remove(LinkedList.java:133)
at
org.drools.common.DefaultAgenda.addActivation(DefaultAgenda.java.446)
at
org.drools.common.DefaultAgenda.modifyActivation(DefaultAgenda.java:382)
at
org.drools.reteoo.RuleTerminalNode.modifyLeftTuple(RuleTerminalNode.java:301)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateModifyChildLeftTuple(SingleLeftTupleSinkAdapter.java:259)
at
org.drools.reteoo.AccumulateNode.exaluateResultConstraints(AccumulateNode.java:676)
at
org.drools.reteoo.ReteooWorkingMemory$EvaluateResultConstraints.execute(ReteooWorkingMemory.java:590)
at
org.drools.common.PropagationContextImpl.evaluateActionQueue(PropagationContextimple:350)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:355)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:311)
at
org.drools.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:903)
at
org.drools.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:847)
at
org.drools.imp.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:269)
at test2.Engine2.main(Engine2.java:80)
However sometimes when it throws the Null pointer exception, it prints out
some of the results of the rules in the middle of the display of the
exception, such as:
java.lang.NullPointerExceptionName1 went A from "msg1" to [msg2]
Name2 went A from "msg1" to [msg2]
at org.drools.core.util.LinkledList.remove(LinkedList.java.133)
and you know the rest.
When I run both rules together, for some reason it seems to run rule One
over the same name and message pair multiple times even though based on the
logic it should only run it based on the first occurrence.
Also I don't know if this matters but there are 361,694 objects that are
entered into the session, 44,269 of which are Foo objects
--
View this message in context:
http://drools.46999.n3.nabble.com/fusion-weird-race-conditions-and-a-null...
Sent from the Drools: User forum mailing list archive at
Nabble.com.