<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>
<div>Shahad</div>
<div> </div>