diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/state/RegionState.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/state/RegionState.java index 8183c15b..fe832501 100644 --- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/state/RegionState.java +++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/state/RegionState.java @@ -110,7 +110,9 @@ public class RegionState extends AbstractState { @Override public void exit(StateContext context) { for (Region region : getRegions()) { - region.getState().exit(context); + if (region.getState() != null) { + region.getState().exit(context); + } region.stop(); } Collection> actions = getExitActions(); diff --git a/spring-statemachine-core/src/test/java/org/springframework/statemachine/state/EndStateTests.java b/spring-statemachine-core/src/test/java/org/springframework/statemachine/state/EndStateTests.java index c21a252f..aff2d059 100644 --- a/spring-statemachine-core/src/test/java/org/springframework/statemachine/state/EndStateTests.java +++ b/spring-statemachine-core/src/test/java/org/springframework/statemachine/state/EndStateTests.java @@ -80,8 +80,7 @@ public class EndStateTests extends AbstractStateMachineTests { assertThat(machine.getState().getIds(), contains(TestStates3.READY)); } - // disable for now, fix in other ticket - //@Test + @Test public void testEndStatesWithRegionsDefinedInStates() throws InterruptedException { context.register(Config3.class); context.refresh();