-
Bug Report
-
Resolution: Fixed
-
L3 - Default
-
7.16.0
-
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.