Uploaded image for project: 'jBPM'
  1. jBPM
  2. JBPM-2679

ExecutionService deleteProcessInstance() and deleteProcessInstanceCascade() silently fails if processinstance is not found

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • jBPM 4.4
    • 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)

      { session.delete(task); }

      // 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)

      { session.delete(job); }

      }

      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)

      { throw new JbpmException("processInstance is not found"); }

      ...

      Attachments

        Activity

          People

            jbarrez Joram Barrez (Inactive)
            h.peter Peter Horvath (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: