Strange Fork Behavior
andre.muniz Jan 20, 2010 12:39 PMHi!
I'm getting an unexpected behavior on the following test process:
When task2 is completed and the execution reaches fork2, JBPM 4.3 is duplicating task3, and I'm getting 3 pending tasks instead of two.
Here is the unit test for this process.
package test2; import java.util.List; import org.jbpm.api.task.Task; import org.jbpm.test.JbpmTestCase; public class ForkTest extends JbpmTestCase { /** Deployment id. */ String deploymentId; /** * Set up. * @throws Exception exception */ protected void setUp() throws Exception { super.setUp(); // XML definition StringBuilder jpdl = new StringBuilder(); jpdl.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); jpdl.append("<process key=\"forkTest\" name=\"Fork Test\" xmlns=\"http://jbpm.org/4.3/jpdl\">"); jpdl.append(" <start g=\"7,137,48,48\" name=\"Lease Termination\">"); jpdl.append(" <transition g=\"-43,-18\" name=\"to fork1\" to=\"fork1\"/>"); jpdl.append(" </start>"); jpdl.append(" <end g=\"841,83,48,48\" name=\"end1\"/>"); jpdl.append(" <fork g=\"118,140,48,48\" name=\"fork1\">"); jpdl.append(" <transition g=\"-44,-18\" name=\"to task1\" to=\"task1\"/>"); jpdl.append(" <transition g=\"-44,-18\" name=\"to task2\" to=\"task2\"/>"); jpdl.append(" </fork>"); jpdl.append(" <task candidate-groups=\"leasing\" g=\"231,71,92,52\" name=\"task1\">"); jpdl.append(" <transition name=\"to join2\" to=\"join2\" g=\"-41,-18\"/>"); jpdl.append(" </task>"); jpdl.append(" <task candidate-groups=\"leasing\" g=\"230,225,92,52\" name=\"task2\">"); jpdl.append(" <transition name=\"to fork2\" to=\"fork2\" g=\"-43,-18\"/>"); jpdl.append(" </task>"); jpdl.append(" <task candidate-groups=\"leasing\" g=\"507,188,92,52\" name=\"task3\">"); jpdl.append(" <transition g=\"-41,-18\" name=\"to join1\" to=\"join1\"/>"); jpdl.append(" </task>"); jpdl.append(" <task candidate-groups=\"leasing\" g=\"511,306,92,52\" name=\"task4\">"); jpdl.append(" <transition g=\"-41,-18\" name=\"to join1\" to=\"join1\"/>"); jpdl.append(" </task>"); jpdl.append(" <join g=\"653,244,48,48\" name=\"join1\">"); jpdl.append(" <transition g=\"-44,-18\" name=\"to task5\" to=\"task5\"/>"); jpdl.append(" </join>"); jpdl.append(" <task candidate-groups=\"leasing\" g=\"781,237,92,52\" name=\"task5\">"); jpdl.append(" <transition g=\"-41,-18\" name=\"to join2\" to=\"join2\"/>"); jpdl.append(" </task>"); jpdl.append(" <join g=\"674,80,48,48\" name=\"join2\">"); jpdl.append(" <transition g=\"-42,-18\" name=\"to end1\" to=\"end1\"/>"); jpdl.append(" </join>"); jpdl.append(" <fork g=\"402,232,48,48\" name=\"fork2\">"); jpdl.append(" <transition g=\"-44,-18\" name=\"to task3\" to=\"task3\"/>"); jpdl.append(" <transition g=\"-44,-18\" name=\"to task4\" to=\"task4\"/>"); jpdl.append(" </fork>"); jpdl.append("</process>"); // Deploys the process deploymentId = repositoryService.createDeployment().addResourceFromString("forkTest.jpdl.xml", jpdl.toString()) .deploy(); } /** * Tear down. * @throws Exception exception */ protected void tearDown() throws Exception { repositoryService.deleteDeploymentCascade(deploymentId); super.tearDown(); } /** * Tests the process. */ public void testProcess() { // Starts a new process instance executionService.startProcessInstanceByKey("forkTest"); // Collection to store the pending tasks List < Task > taskList = null; // Sets if it's to check the number of tasks after the fork2 (2 tasks - task3 and task4) boolean checkNumberOfTasks = false; // Loop do { // Gets the pending tasks taskList = taskService.createTaskQuery().list(); // If it's to check the number of tasks, do it if (checkNumberOfTasks) { assertEquals(2, taskList.size()); break; } // Iterates the tasks list for (Task t : taskList) { // If the execution reaches the task2, changes the boolean, so the next iteration checks the number of tasks if ("task2".equals(t.getName())) checkNumberOfTasks = true; // Completes the task taskService.completeTask(t.getId()); } } while (taskList != null && taskList.size() > 0); } }
Does anyone have any idea what is going on? Thanks!