spring-projects / spring-statemachine

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

having multiple valid transitions for a single event has undetermined behavior #1012

Open kkoo95 opened 2 years ago

kkoo95 commented 2 years ago

When configuring transitions somehow like this:

transitions
  .withExternal()
      .source(TestStates.S1)
      .target(TestStates.S2)
      .event(TestEvents.E1)
          .guard(someGuard1)
      .and()
  .withExternal()
      .source(TestStates.S1)
      .target(TestStates.S3)
           .guard(someGuard2)
      .event(TestEvents.E1)
  .withExternal()
      .source(TestStates.S2)
      .target(TestStates.S22)

If both guards returns true, states are not always entered the same way. sometimes it will be TestStates.S1, TestStates.S2, TestStates.S22 or sometime, TestStates.S1, TestStates.S3

Seems like it happens because ReactiveStateMachineExcecutor uses a HashMap instead of LinkedHashMap for triggerToTransitionMap. Is it on purpose ? Is my config wrong ?