Use `Threading` for virtual thread support

See gh-46404

Signed-off-by: Sangmin Park <sangmins930@gmail.com>
This commit is contained in:
Sangmin Park 2025-07-11 14:14:02 +09:00 committed by Phillip Webb
parent 7098c8e766
commit 53ff2de58e
1 changed files with 2 additions and 3 deletions

View File

@ -18,7 +18,7 @@ package org.springframework.boot.reactor;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.env.EnvironmentPostProcessor; import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.boot.system.JavaVersion; import org.springframework.boot.thread.Threading;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
@ -56,8 +56,7 @@ public class ReactorEnvironmentPostProcessor implements EnvironmentPostProcessor
} }
} }
} }
if (environment.getProperty("spring.threads.virtual.enabled", boolean.class, false) if (Threading.VIRTUAL.isActive(environment)) {
&& JavaVersion.getJavaVersion().isEqualOrNewerThan(JavaVersion.TWENTY_ONE)) {
System.setProperty("reactor.schedulers.defaultBoundedElasticOnVirtualThreads", "true"); System.setProperty("reactor.schedulers.defaultBoundedElasticOnVirtualThreads", "true");
} }
} }