Describe the bug
When completing a parallel multi-instance (会签) user task, the engine throws a NullPointerException because execution is null inside MultiInstanceActivityBehavior.setLoopVariable(), called from ParallelMultiInstanceBehavior.leave().
Stack trace
java.lang.NullPointerException: Cannot invoke "org.flowable.engine.delegate.DelegateExecution.setVariableLocal(String, Object)" because "execution" is null at org.flowable.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior.setLoopVariable(MultiInstanceActivityBehavior.java:579) at org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior.leave(ParallelMultiInstanceBehavior.java:296) at org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior.internalLeave(ParallelMultiInstanceBehavior.java:233) at org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior.leave(ParallelMultiInstanceBehavior.java:174) at org.flowable.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior.leave(AbstractBpmnActivityBehavior.java:60) at org.flowable.engine.impl.bpmn.behavior.UserTaskActivityBehavior.trigger(UserTaskActivityBehavior.java:340) at org.flowable.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior.trigger(MultiInstanceActivityBehavior.java:325) ... at org.flowable.engine.impl.TaskServiceImpl.complete(TaskServiceImpl.java:236)
Environment
- Flowable version: 7.2.0
- Integration:
flowable-spring-boot-starter 7.2.0
- Java: 17
- Database: PostgreSQL (if relevant: we use default Flowable schema; column
IS_MI_ROOT_ / is_mi_root_ exists on ACT_RU_EXECUTION)
To Reproduce
- Deploy a process with a parallel multi-instance user task (e.g. 2 instances, assignee list from a variable).
- Start the process so that the MI activity creates 2 child executions and 2 tasks.
- Complete one of the user tasks (e.g. via
taskService.complete(taskId) or REST).
- The NPE occurs during that
complete() call when the engine runs ParallelMultiInstanceBehavior.leave() and then setLoopVariable(execution, ...) with a null execution.
Expected behavior
The first completed instance should leave the activity without error; the multi-instance root execution should be found and used for setLoopVariable, and the second instance should remain active.
Actual behavior
getMultiInstanceRootExecution(execution) (or equivalent) appears to return null, so the execution passed to setLoopVariable is null and an NPE is thrown.
Additional context
- We have two child executions under the MI scope execution; only one task is completed when the error happens.
- The MI scope execution in the DB has multi-instance variables (
nrOfInstances, nrOfCompletedInstances, nrOfActiveInstances). We did not modify Flowable engine code; we only call taskService.complete(taskId) (and before that we update task assignee/category and set process variables on the root execution).
- We tried (without resolving the issue):
- Overriding
Execution.xml to map the is_mi_root_ column (PostgreSQL lowercase) so that isMultiInstanceRoot() is set correctly when loading executions.
- Moving
updateBusinessStatus() and setVariables() to after complete() so that no extra writes touch executions/variables before the engine’s leave logic runs.
- We are happy to provide a minimal BPMN or database snapshot if needed for reproduction.
Describe the bug
When completing a parallel multi-instance (会签) user task, the engine throws a
NullPointerExceptionbecauseexecutionis null insideMultiInstanceActivityBehavior.setLoopVariable(), called fromParallelMultiInstanceBehavior.leave().Stack trace
java.lang.NullPointerException: Cannot invoke "org.flowable.engine.delegate.DelegateExecution.setVariableLocal(String, Object)" because "execution" is null at org.flowable.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior.setLoopVariable(MultiInstanceActivityBehavior.java:579) at org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior.leave(ParallelMultiInstanceBehavior.java:296) at org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior.internalLeave(ParallelMultiInstanceBehavior.java:233) at org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior.leave(ParallelMultiInstanceBehavior.java:174) at org.flowable.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior.leave(AbstractBpmnActivityBehavior.java:60) at org.flowable.engine.impl.bpmn.behavior.UserTaskActivityBehavior.trigger(UserTaskActivityBehavior.java:340) at org.flowable.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior.trigger(MultiInstanceActivityBehavior.java:325) ... at org.flowable.engine.impl.TaskServiceImpl.complete(TaskServiceImpl.java:236)
Environment
flowable-spring-boot-starter7.2.0IS_MI_ROOT_/is_mi_root_exists onACT_RU_EXECUTION)To Reproduce
taskService.complete(taskId)or REST).complete()call when the engine runsParallelMultiInstanceBehavior.leave()and thensetLoopVariable(execution, ...)with a nullexecution.Expected behavior
The first completed instance should leave the activity without error; the multi-instance root execution should be found and used for
setLoopVariable, and the second instance should remain active.Actual behavior
getMultiInstanceRootExecution(execution)(or equivalent) appears to return null, so the execution passed tosetLoopVariableis null and an NPE is thrown.Additional context
nrOfInstances,nrOfCompletedInstances,nrOfActiveInstances). We did not modify Flowable engine code; we only calltaskService.complete(taskId)(and before that we update task assignee/category and set process variables on the root execution).Execution.xmlto map theis_mi_root_column (PostgreSQL lowercase) so thatisMultiInstanceRoot()is set correctly when loading executions.updateBusinessStatus()andsetVariables()to aftercomplete()so that no extra writes touch executions/variables before the engine’s leave logic runs.