Fix problems in JoinPseudoState

- Fix possible NPE which is a regression.
- Fix state entry notification for JOIN states.
- Fixes #229
This commit is contained in:
Janne Valkealahti
2016-11-06 14:39:19 +00:00
parent c48f671ee1
commit d1f7f31aeb
6 changed files with 1187 additions and 2 deletions

View File

@@ -105,7 +105,8 @@ public class JoinPseudoState<S, E> extends AbstractPseudoState<S, E> {
@Override
public void onEntry(StateContext<S, E> context) {
if (StateMachineUtils.isPseudoState(context.getTransition().getTarget(), PseudoStateKind.END)) {
if (context.getTransition() != null && StateMachineUtils
.isPseudoState(context.getTransition().getTarget(), PseudoStateKind.END)) {
if (!notified && track.size() > 0) {
track.remove(t);
if (track.size() == 0) {

View File

@@ -1142,7 +1142,11 @@ public abstract class AbstractStateMachine<S, E> extends StateMachineObjectSuppo
}
}
notifyStateEntered(buildStateContext(Stage.STATE_ENTRY, message, transition, getRelayStateMachine(), null, state));
// with linked joins, we need to enter state but should not notify.
// state entries are needed to track join logic.
if (!StateMachineUtils.isPseudoState(state, PseudoStateKind.JOIN)) {
notifyStateEntered(buildStateContext(Stage.STATE_ENTRY, message, transition, getRelayStateMachine(), null, state));
}
log.debug("Enter state=[" + state + "]");
state.entry(stateContext);
}