You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been experimenting recently with project Loom by replacing various thread pools with virtual thread executors and running my application with -Djdk.tracePinnedThreads=full JVM option to see if there are any problems with this setup. The stack trace below popped up when I replaced Tomcat's default thread pool with virtual thread executor and went to the /swagger-ui.html page via internet browser:
The virtual thread becomes pinned because AbstractOpenApiResource.getOpenApi method is synchronized and it indirectly calls OpenAPIService.initializeHiddenRestController which blocks the thread by waiting for parallel stream.
Please consider replacing synchronized modifier with ReentrantLock to circumvent thread pinning.
To Reproduce
JDK 20 with --enable-preview and -Djdk.tracePinnedThreads=full switches
spring-boot version: 3.0.6
springdoc-openapi version: 2.1.0
Replace Tomcat's thread pool with virtual thread executor. In my case I defined following Spring Bean to achieve this:
Thread pinning should not happen i.e. rendering swagger-ui.html page should not produce any stacktrace in standard output when -Djdk.tracePinnedThreads=full switch is provided to the JVM.
Additional context
Thread pinning only happens the first time swagger-ui.html page is rendered or every time if springdoc.cache.disabled property is set to true.
The text was updated successfully, but these errors were encountered:
Describe the bug
I've been experimenting recently with project Loom by replacing various thread pools with virtual thread executors and running my application with -Djdk.tracePinnedThreads=full JVM option to see if there are any problems with this setup. The stack trace below popped up when I replaced Tomcat's default thread pool with virtual thread executor and went to the /swagger-ui.html page via internet browser:
The virtual thread becomes pinned because
AbstractOpenApiResource.getOpenApi
method is synchronized and it indirectly callsOpenAPIService.initializeHiddenRestController
which blocks the thread by waiting for parallel stream.Please consider replacing
synchronized
modifier withReentrantLock
to circumvent thread pinning.To Reproduce
--enable-preview
and-Djdk.tracePinnedThreads=full
switchesReplace Tomcat's thread pool with virtual thread executor. In my case I defined following Spring Bean to achieve this:
Expected behavior
Thread pinning should not happen i.e. rendering swagger-ui.html page should not produce any stacktrace in standard output when
-Djdk.tracePinnedThreads=full
switch is provided to the JVM.Additional context
Thread pinning only happens the first time swagger-ui.html page is rendered or every time if
springdoc.cache.disabled
property is set totrue
.The text was updated successfully, but these errors were encountered: