update 优化 AsyncConfig 虚拟线程名称支持

2.X
疯狂的狮子Li 11 months ago
parent c5551976cb
commit 377f7c249f

@ -5,7 +5,7 @@ import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.SpringUtils; import org.dromara.common.core.utils.SpringUtils;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.core.task.VirtualThreadTaskExecutor;
import org.springframework.scheduling.annotation.AsyncConfigurer; import org.springframework.scheduling.annotation.AsyncConfigurer;
import java.util.Arrays; import java.util.Arrays;
@ -18,7 +18,6 @@ import java.util.concurrent.Executor;
* *
* @author Lion Li * @author Lion Li
*/ */
@ConditionalOnProperty(prefix = "spring.threads.virtual", name = "enabled", havingValue = "false")
@AutoConfiguration @AutoConfiguration
public class AsyncConfig implements AsyncConfigurer { public class AsyncConfig implements AsyncConfigurer {
@ -27,6 +26,9 @@ public class AsyncConfig implements AsyncConfigurer {
*/ */
@Override @Override
public Executor getAsyncExecutor() { public Executor getAsyncExecutor() {
if(SpringUtils.isVirtual()) {
return new VirtualThreadTaskExecutor("async-");
}
return SpringUtils.getBean("scheduledExecutorService"); return SpringUtils.getBean("scheduledExecutorService");
} }

Loading…
Cancel
Save