From d29c240ad0091a90d7d5e1d74c3829085784ea63 Mon Sep 17 00:00:00 2001 From: Janne Valkealahti Date: Fri, 15 May 2015 15:15:26 +0100 Subject: [PATCH] Fix possible NPE in RegionState --- .../org/springframework/statemachine/state/RegionState.java | 4 +++- .../org/springframework/statemachine/state/EndStateTests.java | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) 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();