spring-projects / spring-statemachine

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

State action is called twice in sub-submachine with fork/join #1138

Open errd opened 5 months ago

errd commented 5 months ago

Hi there!

Faced the issue when my state action is called twice when expected behaviour is to run once. Here is my state machine:

Screenshot 2024-01-30 at 11 15 35

The problem is that for some reason method setCurrentState of AbstractStateMachine is called twice for state STATE_11. Once from line 991 return setCurrentState(f, message, transition, false, stateMachine, null, fps.getForks()); and another one on line 999 return setCurrentState(toState, message, transition, true, stateMachine, null, targets); And this leads to execution of handlers and actions twice.

I created a demo project with described behaviour: https://github.com/errd/spring-state-machine-example Please find in the project a test placed in StateMachineTest class.

The problem persists only when I have fork/join in the submachine, with fork/join on the first level everything works as expected.

Am I missing something from configuration point of view? Thanks in advance!