If we want to delete super process instance and sub process instance via deleteProcessInstances we get a NPE.
If we use the async method we got:
org.camunda.bpm.engine.BadUserRequestException: No process instance found for id '10': processInstance is null .
We should ensure that if the subprocess is already deleted, we should skip deleting it again.
How to reproduce:
- Change RuntimeServiceAsyncOperationsTest#testDeleteProcessInstancesAsyncWithoutSkipSubprocesses to:
[...] final List<ProcessInstance> list = runtimeService.createProcessInstanceQuery() .list(); // when Batch batch = runtimeService.deleteProcessInstancesAsync(Arrays.asList(list.get(0).getId(), list.get(1).getId()), null, TESTING_INSTANCE_DELETE, false, false); executeSeedJob(batch); executeBatchJobs(batch); [...]
- Add test in CallActivityTest:
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivity.testCallSimpleSubProcess.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml" }) public void testS() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("callSimpleSubProcess"); // one task in the subprocess should be active after starting the process instance TaskQuery taskQuery = taskService.createTaskQuery(); Task taskBeforeSubProcess = taskQuery.singleResult(); assertEquals("Task before subprocess", taskBeforeSubProcess.getName()); // Completing the task continues the process which leads to calling the subprocess taskService.complete(taskBeforeSubProcess.getId()); Task taskInSubProcess = taskQuery.singleResult(); assertEquals("Task in subprocess", taskInSubProcess.getName()); runtimeService.deleteProcessInstances(Arrays.asList(processInstance.getId(), taskInSubProcess.getExecutionId()), "thats why", false, false); }