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

TypedValueBuilders as execution variable lose transient flag

    • Icon: Bug Report Bug Report
    • Resolution: Fixed
    • Icon: L3 - Default L3 - Default
    • 7.17.0, 7.17.0-alpha5
    • 7.16.0
    • engine
    • None

      Environment (Required on creation):

      • All distros

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

      • Setting a variable with a value of TypedValueBuilder on an execution ignores the "transient" flag of that builder.
      • Other API methods regarding variables allow to set TypedValueBuilders and treat those values similar to TypedValues, e.g. by calling #create on them and handling the created TypedValue henceforth

      Steps to reproduce (Required on creation):

       

      @Test
      public void testTransientVariable() {
        BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("foo")
          .startEvent()
          .serviceTask()
            .camundaDelegateExpression("${fooDelegate}").camundaAsyncAfter()
          .endEvent()
          .done();
        testRule.deploy(modelInstance);  JavaDelegate delegate = execution -> execution.setVariable("myVar", Variables.objectValue("Oops", true));
        Mocks.register("fooDelegate",delegate);
        // when
        ProcessInstance pi = runtimeService.startProcessInstanceByKey("foo");
        // then
        assertThat(runtimeService.getVariables(pi.getId())).doesNotContainKey("myVar");
      }

       

      Observed Behavior (Required on creation):

      The variable "myVar" is stored in the execution

      Expected behavior (Required on creation):

      The variable should not be stored since it's transient.

      Root Cause (Required on prioritization):

      • AbstractVariableScope#setVariableLocal calls Variables#untypedValue(Object)
      • The untypedValue method only inspects TypedValues' transient flag, builders are handled as ordinary objects and are marked as non-transient

      Solution Ideas (Optional):

      • Variables#untypedValue(Object) additionally check for TypedValueBuilders and pass on the transient flag correctly.

      Hints (optional):

        This is the controller panel for Smart Panels app

            [CAM-14189] TypedValueBuilders as execution variable lose transient flag

            Christoph Ewerlin created issue -
            Tobias Metzke-Bernstein made changes -
            Link New: This issue is related to CAMTEAM-209 [ CAMTEAM-209 ]
            Tobias Metzke-Bernstein made changes -
            Assignee New: Tobias Metzke-Bernstein [ tobias.metzke ]

            Hey criew,

            thanks for bringing this up. We will have a look as soon as possible and keep you up to date with any insights in this ticket.

            Best,
            Tobias

            Tobias Metzke-Bernstein added a comment - Hey criew , thanks for bringing this up. We will have a look as soon as possible and keep you up to date with any insights in this ticket. Best, Tobias
            Tobias Metzke-Bernstein made changes -
            Mentioned Roles
            Tobias Metzke-Bernstein made changes -
            Mentioned Groups

            Hey criew,

            thanks again for providing this with all the details, that helped a lot in getting to the core of this faster!
            I can reproduce this and I think it's valid to assume the transient flag is preserved correctly for TypedValueBuilders as well

            I have a simple solution in mind that I will give a try within the next couple of days.
            I will keep you posted with the results of that.

            In case this needs more code than I currently assume, we will prioritize this properly for our roadmap.
            It might be that we don't fix this fast then since using "create()" with the builder before setting the variable solves this quite conveniently and also is the documented way of using the object values.

            We'll keep you in the loop.

            Thanks again and best regards,
            Tobias

            Tobias Metzke-Bernstein added a comment - Hey criew , thanks again for providing this with all the details, that helped a lot in getting to the core of this faster! I can reproduce this and I think it's valid to assume the transient flag is preserved correctly for TypedValueBuilders as well I have a simple solution in mind that I will give a try within the next couple of days. I will keep you posted with the results of that. In case this needs more code than I currently assume, we will prioritize this properly for our roadmap. It might be that we don't fix this fast then since using "create()" with the builder before setting the variable solves this quite conveniently and also is the documented way of using the object values. We'll keep you in the loop. Thanks again and best regards, Tobias
            Tobias Metzke-Bernstein made changes -
            Mentioned Roles
            Tobias Metzke-Bernstein made changes -
            Mentioned Groups
            Tobias Metzke-Bernstein made changes -
            Status Original: Open [ 1 ] New: In Progress [ 3 ]

              Unassigned Unassigned
              criew Christoph Ewerlin
              Tobias Metzke-Bernstein Tobias Metzke-Bernstein
              Nikola Koevski Nikola Koevski
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: