Fix exit logic with fork/join

- In a case where fork/join happens within a substate we should not exit parent state
  which causes cascading stops for forked regions thus causing inconsistent lifecycle
  states within that kind of a machine structure. This for example caused parent submachine
  to end up stopped and all regions running even if some regions ended up into terminal state.
- Fixes #737
This commit is contained in:
Janne Valkealahti
2019-05-03 09:50:35 +01:00
parent dc72cc4982
commit 55b7ff09cf
2 changed files with 200 additions and 0 deletions

View File

@@ -1222,6 +1222,16 @@ public abstract class AbstractStateMachine<S, E> extends StateMachineObjectSuppo
if (isPseudoStateSubstate(findDeep, targets)) {
return;
}
if (StateMachineUtils.isSubstate(currentState, transition.getTarget())) {
// don't exit if we're targeting fork within a substate or other
// pseudostate if we're within region.
if (currentState.isSubmachineState()
&& StateMachineUtils.isPseudoState(transition.getTarget(), PseudoStateKind.FORK)) {
return;
} else if (currentState.isOrthogonal()) {
return;
}
}
} else if (findDeep != null && findDeep != state && findDeep.getStates().contains(state)) {
} else if (!isSubOfSource && !isSubOfTarget) {
return;