Fix DistributedStateMachine internal transition
- For some reason ZookeeperStateMachineEnsemble may return null for very early when postTransition() is handled. Adding check not to ping back ensemble if its getState() returns null. It really feels a bit wrong right now, so need to follow this.
This commit is contained in:
@@ -218,9 +218,13 @@ public class DistributedStateMachine<S, E> extends LifecycleObjectSupport implem
|
||||
&& ObjectUtils.nullSafeEquals(delegate.getId(),
|
||||
stateContext.getMessageHeader(StateMachineSystemConstants.STATEMACHINE_IDENTIFIER))) {
|
||||
StateMachineContext<S, E> current = ensemble.getState();
|
||||
ensemble.setState(new DefaultStateMachineContext<S, E>(
|
||||
current.getState(), stateContext.getEvent(), stateContext
|
||||
.getMessageHeaders(), stateContext.getStateMachine().getExtendedState()));
|
||||
if (current != null) {
|
||||
// TODO: it feels a bit wrong that this can be null so
|
||||
// adding note here. feel this will come back to haunt us
|
||||
ensemble.setState(new DefaultStateMachineContext<S, E>(
|
||||
current.getState(), stateContext.getEvent(), stateContext
|
||||
.getMessageHeaders(), stateContext.getStateMachine().getExtendedState()));
|
||||
}
|
||||
}
|
||||
return stateContext;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user