Details
-
Bug
-
Resolution: Done
-
Major
-
jBPM 4.x
-
None
-
None
Description
ExecutionService deleteProcessInstance() and deleteProcessInstanceCascade() should throw an exception if the specified process instance is not found.
Current ExecutionService deleteProcessInstance() and deleteProcessInstanceCascade() implementations call the method public void deleteProcessInstance(String processInstanceId, boolean deleteHistory) in DbSessionImpl
The code tries to lookup the process instance, but the deletion is only attempted if the process instance is found:
ExecutionImpl processInstance = (ExecutionImpl) findProcessInstanceByIdIgnoreSuspended(processInstanceId);
if (processInstance!=null) {
// delete remaining tasks for this process instance
List<TaskImpl> tasks = findTasks(processInstanceId);
for (TaskImpl task: tasks)
// delete remaining jobs for this process instance
JobImpl currentJob = EnvironmentImpl.getFromCurrent(JobImpl.class, false);
List<JobImpl> jobs = findJobs(processInstanceId);
for (JobImpl job: jobs) {
if (job!=currentJob)
}
if (log.isDebugEnabled())
{ log.debug("deleting process instance "+processInstanceId); } session.delete(processInstance);
}
Since not finding a process instance usually indicates an error, the method should throw an exception to notify caller code.
I think this code should be modified to throw an exception if the process instance is not found:
ExecutionImpl processInstance = (ExecutionImpl) findProcessInstanceByIdIgnoreSuspended(processInstanceId);
if (processInstance==null)
...