spring-projects / spring-statemachine

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

AbstractStateMachineFactory.getStateMachine(AbstractStateMachineFactory.java:148) uses BLOCKING java.util.UUID.randomUUID(UUID.java:150) #859

Open patpatpat123 opened 4 years ago

patpatpat123 commented 4 years ago

Hello Spring State Machine team,

This project is very cool. We are using spring-statemachine-core-2.2.0.RELEASE.jar combined with spring web flux. During one of our test with BlockHound, we found out getStateMachine is a blocking call.

2020-07-27 06:26:25.403 ERROR 14756 --- [ parallel-2] a.w.r.e.AbstractErrorWebExceptionHandler : [2b9817be] 500 Server Error for HTTP POST "/handler"

reactor.blockhound.BlockingOperationError: Blocking call! java.io.FileInputStream#readBytes at java.io.FileInputStream.readBytes(FileInputStream.java) ~[?:?] Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: Error has been observed at the following site(s): | checkpoint ⇢ Handler someController#xxx(Mono) [DispatcherHandler] | checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain] |_ checkpoint ⇢ HTTP POST "/handler" [ExceptionHandlingWebHandler] Stack trace: at java.io.FileInputStream.readBytes(FileInputStream.java) ~[?:?] at java.io.FileInputStream.read(FileInputStream.java:279) ~[?:?] at java.io.FilterInputStream.read(FilterInputStream.java:133) ~[?:?] at sun.security.provider.NativePRNG$RandomIO.readFully(NativePRNG.java:424) ~[?:?] at sun.security.provider.NativePRNG$RandomIO.ensureBufferValid(NativePRNG.java:526) ~[?:?] at sun.security.provider.NativePRNG$RandomIO.implNextBytes(NativePRNG.java:545) ~[?:?] at sun.security.provider.NativePRNG.engineNextBytes(NativePRNG.java:220) ~[?:?] at java.security.SecureRandom.nextBytes(SecureRandom.java:741) ~[?:?] at java.util.UUID.randomUUID(UUID.java:150) ~[?:?] at org.springframework.statemachine.support.AbstractStateMachine.(AbstractStateMachine.java:168) ~[spring-statemachine-core-2.2.0.RELEASE.jar:2.2.0.RELEASE] at org.springframework.statemachine.ObjectStateMachine.(ObjectStateMachine.java:63) ~[spring-statemachine-core-2.2.0.RELEASE.jar:2.2.0.RELEASE] at org.springframework.statemachine.config.ObjectStateMachineFactory.buildStateMachineInternal(ObjectStateMachineFactory.java:75) ~[spring-statemachine-core-2.2.0.RELEASE.jar:2.2.0.RELEASE] at org.springframework.statemachine.config.AbstractStateMachineFactory.buildMachine(AbstractStateMachineFactory.java:941) ~[spring-statemachine-core-2.2.0.RELEASE.jar:2.2.0.RELEASE] at org.springframework.statemachine.config.AbstractStateMachineFactory.getStateMachine(AbstractStateMachineFactory.java:263) ~[spring-statemachine-core-2.2.0.RELEASE.jar:2.2.0.RELEASE] at org.springframework.statemachine.config.AbstractStateMachineFactory.getStateMachine(AbstractStateMachineFactory.java:148) ~[spring-statemachine-core-2.2.0.RELEASE.jar:2.2.0.RELEASE]

Our project if fully "web flux ready". The only blocking call is this one. Would it be possible to help remediate to this issue, since reactive spring is now a legitimate use case of Spring ecosystem?

I also saw there is a route to reactive with 3.x Can this be part of the 3.x if possible? Because it this is left blocking, 3.x would be non reactive as well.

Thank you very much, good day.

alopukhov commented 4 years ago

Just have to note: there is an overload in StateMachineFactory that takes UUID. So maybe providing uuid youself could solve your problem.