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> &lt;<a href="mailto:shahad.ahmed2@gmail.com">shahad.ahmed2@gmail.com</a>&gt; 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&#39;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&nbsp;created a&nbsp;looping ruleflow that contains a Join and&nbsp; 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&nbsp;the same&nbsp;Split node is re-entered I always get the following exception: 
</div>
<div>&nbsp;</div>
<div>&nbsp;java.lang.IllegalArgumentException: Illegal node type: class org.drools.ruleflow.core.impl.Split<br>&nbsp;at org.drools.ruleflow.instance.impl.RuleFlowProcessInstance.getNodeInstance(RuleFlowProcessInstance.java:121)<br>

&nbsp;at org.drools.ruleflow.instance.impl.RuleFlowSequenceNodeInstance.triggerCompleted(RuleFlowSequenceNodeInstance.java:38)<br>&nbsp;at org.drools.common.RuleFlowGroupImpl$DeactivateCallback.execute(RuleFlowGroupImpl.java:191)<br>

&nbsp;at org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:992)<br>&nbsp;at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:375)<br>&nbsp;at org.drools.common.AbstractWorkingMemory.fireAllRules

 (AbstractWorkingMemory.java:353)<br>&nbsp;at org.drools.examples.SequentialTest.runTest4(SequentialTest.java:192)<br>&nbsp;at org.drools.examples.SequentialTest.main(SequentialTest.java:27)</div>
<div>&nbsp;</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

 &nbsp;&nbsp;I think the return in the following part of the if-then-else is in the wrong place:</div>
<div>&nbsp;</div>
<div>else if ( node instanceof ISplit ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IRuleFlowNodeInstance result = getFirstNodeInstance( node.getId() );<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( result == null ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result = new RuleFlowSplitInstance(); 
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result.setNodeId( node.getId() );<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; addNodeInstance( result );<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return result;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</div>
<div>}...</div>
<div>&nbsp;</div>
<div>This code would mean that the second time&nbsp;the Split is entered, result is not null, so &quot;if ( result == null )&quot; 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 &quot;if ( result == null )&quot; if-statement&nbsp;just like&nbsp;the IJoin part of the if-then-else to give the following (correct?) code: 
</div>
<div>&nbsp;</div>
<div>else if ( node instanceof ISplit ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IRuleFlowNodeInstance result = getFirstNodeInstance( node.getId() );<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( result == null ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result = new RuleFlowSplitInstance(); 
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result.setNodeId( node.getId() );<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; addNodeInstance( result );&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;return result;</div>
<div>}...</div>
<div>&nbsp;</div>
<div>Once I&nbsp;changed the return,&nbsp;looping seemed to work fine. I wasn&#39;t sure about raising a JIRA about this, as this stuff is still under development. </div>
<div>&nbsp;</div>
<div>Regards</div><span class="sg">
<div>Shahad</div>
<div>&nbsp;</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>