Skip to content

Commit

Permalink
fix(engine): prevent NPE during termination
Browse files Browse the repository at this point in the history
A command could contain multiple terminate instruction that result in the termination of the same element instance. For example, when we have a sub process and a nested element. If both this sub process and the nested element are part of the terminate instructions, the nested element will be terminated twice.

When we receive the command we verify that all instances exist. However, once the first terminate instruction terminates the element, the instance no longer exist for the second terminate instruction. When this occurs we should ignore the terminate instruction.
  • Loading branch information
remcowesterhoud committed Oct 4, 2022
1 parent b397826 commit 7bf05d5
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ public void processRecord(
instruction -> {
final var elementInstance =
elementInstanceState.getInstance(instruction.getElementInstanceKey());
if (elementInstance == null) {
// at this point this element instance has already been terminated as a result of
// one of the previous terminate instructions. As a result we no longer need to
// terminate it.
return;
}
final var flowScopeKey = elementInstance.getValue().getFlowScopeKey();

terminateElement(elementInstance, sideEffectQueue);
Expand Down

0 comments on commit 7bf05d5

Please sign in to comment.