spring-statemachine icon indicating copy to clipboard operation
spring-statemachine copied to clipboard

DefaultStateMachineService does not restore state properly

Open azhuchkov opened this issue 4 years ago • 1 comments

DefaultStateMachineService has method restoreStateMachine that restores persisted state into newly created state machine, but it does not work for the case with hierarchical states.

According to DefaultStateMachinePersister and some examples over Internet, FSM should be restored using stateMachine.getStateMachineAccessor().doWithAllRegions(), but DefaultStateMachineService for some reason restores only top level region:

// only go via top region
stateMachine.getStateMachineAccessor().doWithRegion(function -> function.resetStateMachine(stateMachineContext));

azhuchkov avatar May 13 '21 12:05 azhuchkov

Issues that you are experiencing are attempted to be addressed here: https://github.com/spring-projects/spring-statemachine/pull/998

Restoring with top level region is correct, because the function itself is recursive. Actual persisting is broken there, that's why it doesn't work.

chutch avatar Sep 15 '21 12:09 chutch