Hey,
I´m not sure if I do not understand output mapping and scoping the right way, or a bug has crossed my way.
I have two processes with parallel process paths, one with a parallel gateway and one with a multi-instance sub-process.
In both processes a variable called “variable” is initially set in the process instance scope and then changed in each parallel path. In the parallel paths it is changed via output mapping of a script task. After changing the variable, both parallel executions are stopped with a dummy receive task (only for displaying purposes).
What I would expect as “variable” value is:
- Process instance execution: “base”
- Execution 1: “1”
- Execution 2: “2”
What I really get is:
- Process instance execution: “2”
- Execution 1: “2”
- Execution 2: “2”
The technical reason for this is the implementation in class org.camunda.bpm.engine.impl.core.variable.mapping.OutputParameter. It calls setVariable on the outer scope. This means that the variable value is stored in the deepest scope, which has already a value for the variable. If not, the highest scope (the process instance itself) is used.
Without output mapping everything works fine.
If it is not a bug: Where is the mistake in my expectation? How can I change a variable locally with the help of output mapping?
I´ve added a test project to reproduce the situation
Thanks in advance!!
Carsten