-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Description
StateMachineImpl#routeTransitions和StateMachineImpl#routeTransition both have npe
solution :
private Transition<S, E, C> routeTransition(S sourceStateId, E event) {
State sourceState = getState(sourceStateId);
List<Transition<S, E, C>> transitions = sourceState.getEventTransitions(event);
if (transitions == null || transitions.size() == 0) {
return null;
}
return transitions.get(0);
}
.......
private List<Transition<S, E, C>> routeTransitions(S sourceStateId, E event) {
State sourceState = getState(sourceStateId);
List<Transition<S, E, C>> transitions = sourceState.getEventTransitions(event);
return transitions;
}
..........
@OverRide
public S fireEvent(S sourceStateId, E event, C ctx) {
isReady();
Transition<S, E, C> transition = routeTransition(sourceStateId, event);
if (transition == null) {
Debugger.debug("There is no Transition for " + event);
failCallback.onFail(sourceStateId, event, ctx);
return sourceStateId;
}
return transition.transit(ctx).getId();
}
.....
@OverRide
public List fireParallelEvent(S sourceState, E event, C context) {
isReady();
List<Transition<S, E, C>> transitions = routeTransitions(sourceState, event);
List result = new ArrayList<>();
if (transitions == null || transitions.isEmpty()) {
Debugger.debug("There is no Transition for " + event);
failCallback.onFail(sourceState, event, context);
result.add(sourceState);
return result;
}
for (Transition<S, E, C> transition : transitions) {
S id = transition.transit(context).getId();
result.add(id);
}
return result;
}
....
State<S, E, C> transit(C ctx);
.....
@OverRide
public State<S, E, C> transit(C ctx) {
Debugger.debug("Do transition: " + this);
this.verify();
if (condition == null || condition.isSatisfied(ctx)) {
if (action != null) {
action.execute(source.getId(), target.getId(), event, ctx);
}
return target;
}
Debugger.debug("Condition is not satisfied, stay at the " + source + " state ");
return source;
}