flowable / flowable/flowable-engine
variable instance lost because RuntimeService#setVariable behaves like VariableScope#setVariable(_,_,false)
- 主要语言
- Java
- 星标
- 9.5k
- 派生
- 2.9k
- 平均合并
- 7 小时 8 分钟
- 30 天内合并 PR
- 2
描述
We're trying to upgrade from activiti 5.9 to flowable 5.22.0 but our test-cases fail with 5.22.0. We depend on `RuntimeService#setVariable` to set a variable instance for a nested workflow. Unfortunately the variable is gone by the time we need it. Our method works with 5.9.
When debugging we see that `SetExecutionVariablesCmd#execute` is called which executes [VariableScope#setVariable(String variableName, Object value, boolean fetchAllVariables)](http://www.flowable.org/docs/javadocs/org/activiti/engine/delegate/VariableScope.html#setVariable-java.lang.String-java.lang.Object-boolean-) with `fetchAllVariables == false`. This is counter-intuitive to me because the documentation of [RuntimeService#setVariable](http://www.flowable.org/docs/javadocs/org/activiti/engine/RuntimeService.html#setVariable-java.lang.String-java.lang.String-java.lang.Object-) refers to [VariableScope#setVariable(String, Object)](http://www.flowable.org/docs/javadocs/org/activiti/engine/delegate/VariableScope.html#setVariable-java.lang.String-java.lang.Object-) which defaults to `fetchAllVariables == true`.
As a consequence of `fetchAllVariables == false` we end up in `VariableScopeImpl#createVariableInstance` with `variableInstances == null`, the `put` operation doesn't take place and the variable only gets written to the `VariableScopeImpl#usedVariablesCache`.
Is there a call to `VariableScopeImpl#ensureVariableInstancesInitialized()` missing in `VariableScopeImpl#createVariableInstance` or should `SetExecutionVariablesCmd` use `fetchAllVariables == true` or is this a new expected behavior and we should use another method to set our variables?
贡献指南
这个仓库没有索引到贡献指南
调研方向
先阅读 SetExecutionVariablesCmd#execute 和 VariableScopeImpl#createVariableInstance,然后比较 VariableScope#setVariable 各重载的 fetchAllVariables 行为。重现 issue 中描述的嵌套工作流测试失败,并确定预期的行为。完成标准是回归测试证明 RuntimeService#setVariable 保留变量实例,或者在不要求该行为的情况下记录预期的替代方案。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 35/100