Details

    • Sub-task
    • Resolution: Fixed
    • L3 - Default
    • 7.14.0, 7.14.0-alpha4
    • None
    • engine
    • None

    Description

      Steps to reproduce

      Send the following payload:

      POST /process-instance/variables-async
      
      {
        "processInstanceIds": [
          "e54f3dfc-e912-11ea-9c33-16a02d5a3a1d"
        ],
        "variables": {
          "foo": {
            "type": "Object",
            "value": "[\"foo\", \"bar\"]",
            "valueInfo": {
              "objectTypeName": "java.util.ArrayList",
              "serializationDataFormat": "application/json"
            }
          }
        }
      }
      

      Expected behavior

      Variables are set asynchronously.

      Observed behavior

      Batch jobs fail with the following exception:

      java.lang.NullPointerException
      	at org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity.onImplicitValueUpdate(VariableInstanceEntity.java:582)
      	at org.camunda.bpm.engine.impl.persistence.entity.util.TypedValueField.notifyImplicitValueUpdate(TypedValueField.java:183)
      	at org.camunda.bpm.engine.impl.persistence.entity.util.TypedValueField.onCommandContextClose(TypedValueField.java:177)
      	at org.camunda.bpm.engine.impl.interceptor.CommandContext.fireCommandContextClose(CommandContext.java:246)
      	at org.camunda.bpm.engine.impl.interceptor.CommandContext.close(CommandContext.java:185)
      	at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:119)
      	at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:70)
      	at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
      	at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobHelper.executeJob(ExecuteJobHelper.java:57)
      	at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.executeJob(ExecuteJobsRunnable.java:110)
      	at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:71)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:748)
      

      Root cause

      1. With CAM-3442, implicit variable updates were implemented
        • When an object variable is set via an API call and the object reference is kept to modify it later, the engine takes care to check if the variable value has been modified right before the variable is persisted
      2. When setting the variables on batch execution, the batch variable instances are queried, and a map of the variable names and the typed values is created
        • The batch variable instances don't have a reference to a taskId, executionId or caseExecutionId
      3. When calling VariableInstanceEntity#getTypedValue() a command context listener is registered to check on flush if the variable has been updated implicitly
      4. When an XML/JSON serialized object is set, the TypedValue is serialized and compared against the persisted byte array
      5. If the original byte array and the serialized byte array are not equal, a variable update is triggered
        • A difference is spotted since via the REST API the raw string ["foo", "bar"] is persisted; The implicit variable update check is triggered since the space after the comma in the JSON string is removed (due to serialization) so that the byte arrays are different
      6. Since the batch variable instance is not assigned to a taskId, executionId or caseExecutionId, a null pointer exception is thrown when trying to set the variable

      Solution

      On batch job execution, the registration of the command listener for the implicit variable update check is skipped

      mgm-controller-panel

        This is the controller panel for Smart Panels app

        Attachments

          Issue Links

            Activity

              People

                hariharan.parasuraman Hariharan Parasuraman
                tassilo.weidner Tassilo Weidner
                Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:

                  Salesforce