Fix state exit with fork

- Fix a case where state leading into a fork
  doesn't exit.
- Relates to work in #221
This commit is contained in:
Janne Valkealahti
2016-05-08 14:02:56 +01:00
parent 66295d9ed2
commit 751f95b44f
2 changed files with 6 additions and 1 deletions

View File

@@ -81,6 +81,8 @@ public class ForkJoinEntryExitTests extends AbstractBuildTests {
.step().expectState("S1").and()
.step()
.sendEvent("E1")
.expectStateEntered(3)
.expectStateExited(1)
.expectStates("S2", "S210", "S220").and()
.step()
.sendEvent("E2")
@@ -109,8 +111,10 @@ public class ForkJoinEntryExitTests extends AbstractBuildTests {
.step().expectState("S1").and()
.step()
.sendEvent("E1")
.expectStateEntered(3)
.expectStateExited(1)
.expectStates("S2", "S210", "S220").and()
.step()
.step()
.sendEvent("E2")
.expectStateEntered(1)
.expectStateExited(1)

View File

@@ -733,6 +733,7 @@ public abstract class AbstractStateMachine<S, E> extends StateMachineObjectSuppo
// need to check for from original state passed in
kind = toState.getPseudoState() != null ? toState.getPseudoState().getKind() : null;
if (kind == PseudoStateKind.FORK) {
exitCurrentState(toState, message, transition, stateMachine);
ForkPseudoState<S, E> fps = (ForkPseudoState<S, E>) toState.getPseudoState();
for (State<S, E> ss : fps.getForks()) {
callPreStateChangeInterceptors(ss, message, transition, stateMachine);