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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user