Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
patpatpat123 opened this issue Jul 27, 2020 · 1 comment

Comments

@patpatpat123
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants