spring-projects / spring-statemachine

Spring Statemachine is a framework for application developers to use state machine concepts with Spring.
1.52k stars 598 forks source link

StateMachinePersister is not working with Enum states #1073

Open angellopez417 opened 1 year ago

angellopez417 commented 1 year ago

When you use Enum states and want to persist the state machine, using persister.restore is not able to reset the state machine with the storage context.

This logic fails, the Enum does not match:

if (state instanceof Enum && ss.getId() instanceof Enum && state.getClass() == ss.getId().getClass() && ((Enum)ss.getId()).ordinal() == ((Enum)state).ordinal()) { enumMatch = true; }

This is due to this comparison: state.getClass() == ss.getId().getClass() always is false