spring-projects / spring-boot

Spring Boot
https://spring.io/projects/spring-boot
Apache License 2.0
74.57k stars 40.55k forks source link

Auto-configure VirtualThreads bean #36615

Closed mhalbritter closed 1 year ago

mhalbritter commented 1 year ago

We sometimes need to get access to the virtual thread executor. The API is only available on Java 21 so we can't compile against it (without multi-release JARs), but it's possible to get it via reflection. This should be encapsulated in a separate class.

Besides that, sometimes it's nice to have a bean which is only there when virtual threads are enabled, because then you can use an ObjectProvider and write ifs, which is sometimes easier than rearranging the auto-configuration bean methods.

mhalbritter commented 1 year ago

Closed by eeb1e1fc35267f5a200284a8390dccc10fc8b355

mhalbritter commented 1 year ago

We decided to revert that. With #36624 implemented, we can get away without the VirtualThreads bean. If an executor is needed, Spring Framework provides a VirtualThreadTaskExecutor.