Possible defect with hasVariableLocal / setVariableLocal

Hi all,

I may be missing something but it looks like
org.flowable.variable.service.impl.persistence.entity.VariableScopeImpl#hasVariableLocal
org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl#setVariableLocal(java.lang.String, java.lang.Object, org.flowable.engine.impl.persistence.entity.ExecutionEntity, boolean)

have inconsistent implementations w.r.t transient variables.
If the variable exists as a transient variable in the scope hasVariableLocal returns true:\

     if (transientVariables != null && transientVariables.containsKey(variableName)) {
            return true;
     }

However setVariableLocal proceeds with creating a new, non transient variable because it only checks for variable instances:

    if (variableInstance == null) {
                createVariableLocal(variableName, value, sourceExecution);

One would expect scope.setVariable(“foo”) to update the transient variable when it exists. It looks like this was the intentin org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl#setVariable(java.lang.String, java.lang.Object, org.flowable.engine.impl.persistence.entity.ExecutionEntity, boolean):

            // If the variable exists on this scope, replace it
            if (hasVariableLocal(variableName)) {
                setVariableLocal(variableName, value, sourceExecution, true);
                return;
            }

Am I missing something?
Franck

That does look inconsistent. We’ll investigate and continue the discussion in the issue you create setVariable fails to take transient variable into accoun · Issue #2992 · flowable/flowable-engine · GitHub