sounds like a bug. Please do JIRA this, with a test case if you can. I think its settled down a bit, so we should be able to fix things like this now.<br><br>Thanks for looking into it.<br><br>Michael.<br><br><div><span class="gmail_quote">
On 5/21/07, <b class="gmail_sendername">Shahad Ahmed</b> <<a href="mailto:shahad.ahmed2@gmail.com">shahad.ahmed2@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>I've been trying out the latest version of the ruleflow and I think I may have found a bug when creating looping ruleflows. I think the bug is in RuleFlowProcessInstance.getNodeInstance, where I suspect there is a return in the wrong place in the if-then-else that deals with ISplit node. I created a looping ruleflow that contains a Join and Split node, where the Split decides if we should enter the loop and the Join allows a flow to re-enter the loop body. The issues is that the second time the same Split node is re-entered I always get the following exception:
</div>
<div> </div>
<div> java.lang.IllegalArgumentException: Illegal node type: class org.drools.ruleflow.core.impl.Split<br> at org.drools.ruleflow.instance.impl.RuleFlowProcessInstance.getNodeInstance(RuleFlowProcessInstance.java:121)<br>
at org.drools.ruleflow.instance.impl.RuleFlowSequenceNodeInstance.triggerCompleted(RuleFlowSequenceNodeInstance.java:38)<br> at org.drools.common.RuleFlowGroupImpl$DeactivateCallback.execute(RuleFlowGroupImpl.java:191)<br>
at org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:992)<br> at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:375)<br> at org.drools.common.AbstractWorkingMemory.fireAllRules
(AbstractWorkingMemory.java:353)<br> at org.drools.examples.SequentialTest.runTest4(SequentialTest.java:192)<br> at org.drools.examples.SequentialTest.main(SequentialTest.java:27)</div>
<div> </div>
<div>This exception is only thrown if the ruleflow contains an unknown node, but org.drools.ruleflow.core.impl.Split is a valid node (i.e. an instance of ISplit)! Looking at the body of RuleFlowProcessInstance.getNodeInstance
I think the return in the following part of the if-then-else is in the wrong place:</div>
<div> </div>
<div>else if ( node instanceof ISplit ) {<br> IRuleFlowNodeInstance result = getFirstNodeInstance( node.getId() );<br> if ( result == null ) {<br> result = new RuleFlowSplitInstance();
<br> result.setNodeId( node.getId() );<br> addNodeInstance( result );<br> return result;<br> }</div>
<div>}...</div>
<div> </div>
<div>This code would mean that the second time the Split is entered, result is not null, so "if ( result == null )" is never entered, which results in dropping out of the if-then-else and activating the error exception above. I suspect the return should be outside the "if ( result == null )" if-statement just like the IJoin part of the if-then-else to give the following (correct?) code:
</div>
<div> </div>
<div>else if ( node instanceof ISplit ) {<br> IRuleFlowNodeInstance result = getFirstNodeInstance( node.getId() );<br> if ( result == null ) {<br> result = new RuleFlowSplitInstance();
<br> result.setNodeId( node.getId() );<br> addNodeInstance( result ); <br> }</div>
<div> return result;</div>
<div>}...</div>
<div> </div>
<div>Once I changed the return, looping seemed to work fine. I wasn't sure about raising a JIRA about this, as this stuff is still under development. </div>
<div> </div>
<div>Regards</div><span class="sg">
<div>Shahad</div>
<div> </div>
</span><br>_______________________________________________<br>rules-dev mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">
https://lists.jboss.org/mailman/listinfo/rules-dev</a><br><br></blockquote></div><br>