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

NullPointerException is thrown when accessing a JSON typed variable with null value

    XMLWordPrintable

Details

    • Bug Report
    • Resolution: Fixed
    • L3 - Default
    • 7.17.0, 7.17.0-alpha2, 7.16.3
    • 7.17.0, 7.14.13, 7.15.7, 7.16.1
    • None
    • None

    Description

      Environment (Required on creation):

      Any Camunda Platform version >= 7.14.

      Description (Required on creation; please attach any relevant screenshots, stacktraces, log files, etc. to the ticket):

      NullPointerException is thrown when accessing a JSON typed variable with null value:

      java.lang.NullPointerException: Cannot invoke "org.camunda.spin.json.SpinJsonNode.getDataFormatName()" because "value" is null
      	at org.camunda.spin.plugin.impl.JsonValueSerializer.createDeserializedValue(JsonValueSerializer.java:50) ~[camunda-engine-plugin-spin-7.14.0.jar:7.14.0]
      	at org.camunda.spin.plugin.impl.JsonValueSerializer.createDeserializedValue(JsonValueSerializer.java:34) ~[camunda-engine-plugin-spin-7.14.0.jar:7.14.0]
      	at org.camunda.bpm.engine.impl.variable.serializer.AbstractSerializableValueSerializer.readValue(AbstractSerializableValueSerializer.java:88) ~[camunda-engine-7.14.0.jar:7.14.0]
      	at org.camunda.bpm.engine.impl.variable.serializer.AbstractSerializableValueSerializer.readValue(AbstractSerializableValueSerializer.java:31) ~[camunda-engine-7.14.0.jar:7.14.0]
      	at org.camunda.bpm.engine.impl.persistence.entity.util.TypedValueField.getTypedValue(TypedValueField.java:115) ~[camunda-engine-7.14.0.jar:7.14.0]
      	at org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity.getTypedValue(VariableInstanceEntity.java:282) ~[camunda-engine-7.14.0.jar:7.14.0]
      	at org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableScope.getTypedValueFromVariableInstance(AbstractVariableScope.java:173) ~[camunda-engine-7.14.0.jar:7.14.0]
      	at org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableScope.getVariableTyped(AbstractVariableScope.java:159) ~[camunda-engine-7.14.0.jar:7.14.0]
      	at org.camunda.bpm.engine.impl.cmd.GetExecutionVariableTypedCmd.execute(GetExecutionVariableTypedCmd.java:65) ~[camunda-engine-7.14.0.jar:7.14.0]
      	at org.camunda.bpm.engine.impl.cmd.GetExecutionVariableTypedCmd.execute(GetExecutionVariableTypedCmd.java:33) ~[camunda-engine-7.14.0.jar:7.14.0]
      	at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:28) ~[camunda-engine-7.14.0.jar:7.14.0]
      	at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:110) ~[camunda-engine-7.14.0.jar:7.14.0]
      

      Steps to reproduce (Required on creation):

      • Store a JSON typed variable with null value e.g. on process instance start
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("my-project-process",
            Variables.createVariables().putValue("jsonNull", SpinValues.jsonValue((String) null).create()));
      • Retrieve the variable deserialized
        runtimeService.getVariableTyped(processInstance.getProcessInstanceId(), "jsonNull", true);

      Observed Behavior (Required on creation):

      A NullPointerException is thrown.

      Expected behavior (Required on creation):

      No NullPointerException is thrown, instead a JsonValueImpl with value null is returned.

      Root Cause (Required on prioritization):

      Implementation is not null safe: In JsonValueSerializer#createDeserializedValue the accessor #getDataFormatName is called on the parameter deserializedObject although it is null.

      Solution Ideas (Optional):

      1. Make JsonValueSerializer#createDeserializedValue return SpinValues.jsonValue((String)null).create() in case the serialized value is null.
      2. Replace value.getDataFormatName() with dataFormat.getName()

      Hints (optional):

      I created the following engine test case using GraalJS for debugging reasons:
      https://github.com/camunda/camunda-bpm-platform/commit/8b723918ee1bc6a65d1251292c8e06f7a372db73
      Do not merge to master since it's hacky.

      mgm-controller-panel

        This is the controller panel for Smart Panels app

        Attachments

          Activity

            People

              tassilo.weidner Tassilo Weidner
              tassilo.weidner Tassilo Weidner
              Tassilo Weidner Tassilo Weidner
              Daniel Kelemen Daniel Kelemen
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Salesforce