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:
Janne Valkealahti
2015-08-07 17:18:12 +01:00
parent bba3b231b3
commit 435b306cf9

View File

@@ -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;
}