Uploaded image for project: 'camunda BPM'
  1. camunda BPM
  2. CAM-9543

Closing case programmatically fails when case is configured to auto-complete

XMLWordPrintable

    • Icon: Bug Report Bug Report
    • Resolution: Won't Fix
    • Icon: L3 - Default L3 - Default
    • None
    • 7.9.0, 7.9.5
    • cmmn model api, engine
    • None

      Goal:
      Create a case model that is called from a parent process. The case model should be configured to auto-complete when all tasks are finished. Additionally, the case should be closed upon completion to remove it from the runtime database.

      Configuration

      • BPMN file is configured to call the CMMN model
      • Case model is configured with a single human task
      • Case model is configured to auto-complete when the task is completed
      • Case model is configured with an Event Listener that fires on the "complete" transition and invokes the close() method to close the case.

      Expected Outcome:
      The case model should be completed and closed.

      Actual Outcome:
      The event listener throws an exception when close() is invoked because close() attempts to perform a transition to the "complete" state. However, this call is being made from within a "complete" event listener as the model is configured to auto-complete. The exception indicates that the case cannot be transitioned to the status of complete because it is already in that status. However, the engine was not requested to move the case to complete. It was requested to move the existing completed case to a status of "closed". The engine is performing an additional unnecessary step that results in an exception.

      Sample Error Log Entry:
      The following log entry is output when a user completes the sole human task on a model that is configured to auto-complete and has an event listener that attempts to close the case upon completion.

      25-Nov-2018 21:29:50.621 WARNING [http-nio-8080-exec-1] org.camunda.bpm.engine.rest.exception.RestExceptionHandler.toResponse org.camunda.bpm.engine.rest.exception.RestException: Cannot submit task form 849142b7-f12b-11e8-b5cc-ba69031f8e06: ENGINE-05010 Could not perform transition 'complete on case execution with id '84911ba5-f12b-11e8-b5cc-ba69031f8e06'.Reason: The case execution is already in state 'completed'.

      Desired Fix:
      The close() invocation should not first attempt to "complete" a case if it has already been completed. The engine should identify that the case is already in a state that is eligible for transition to "closed" and should simply perform the requested operation. It may be reasonable for the close() method to perform a preliminary "complete" transition if the case was not already in that state, but it should not throw an exception for a legitimate transition request. The engine should either

      1. Catch the transition exception and ignore it in this instance, or
      2. Preferably, evaluate the current state of the case and only conditionally invoke the transition to "complete" when necessary prior to transitioning to the requested "closed" state.

      Steps to reproduce:

      • Deploy the attached BPMN and CMMN file to an engine instance via REST API.
      • Use tasklist to start the Case Listener Close Failure process. The BPMN will call the case model and create a single human task.
      • Use tasklist to complete the Human Task
      • Observe the error output as noted above

        This is the controller panel for Smart Panels app

          1. case_listener_close_failure.bpmn
            3 kB
            Daniel Hallmark
          2. case_listener_close_failure.cmmn
            2 kB
            Daniel Hallmark

              Unassigned Unassigned
              dhallmark Daniel Hallmark
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: