From a07e5d783374f379cf51e74be5cd2b54fa6147aa Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期一, 22 一月 2024 13:02:43 +0800
Subject: [PATCH] update 优化 解除注释 使用spring包装虚拟线程池无须担心idea警告问题

---
 ruoyi-admin/src/main/resources/application.yml                                                |    1 -
 ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/config/UndertowConfig.java |   14 ++++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml
index 0f116d9..736cdf6 100644
--- a/ruoyi-admin/src/main/resources/application.yml
+++ b/ruoyi-admin/src/main/resources/application.yml
@@ -64,7 +64,6 @@
     name: ${ruoyi.name}
   threads:
     # 寮�鍚櫄鎷熺嚎绋� 浠卝dk21鍙敤
-    # 寮�鍚悗杩橀渶鏇存敼 UndertowConfig 铏氭嫙绾跨▼閰嶇疆
     virtual:
       enabled: false
   # 璧勬簮淇℃伅
diff --git a/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/config/UndertowConfig.java b/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/config/UndertowConfig.java
index df483a3..0f78928 100644
--- a/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/config/UndertowConfig.java
+++ b/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/config/UndertowConfig.java
@@ -2,9 +2,11 @@
 
 import io.undertow.server.DefaultByteBufferPool;
 import io.undertow.websockets.jsr.WebSocketDeploymentInfo;
+import org.dromara.common.core.utils.SpringUtils;
 import org.springframework.boot.autoconfigure.AutoConfiguration;
 import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
 import org.springframework.boot.web.server.WebServerFactoryCustomizer;
+import org.springframework.core.task.VirtualThreadTaskExecutor;
 
 /**
  * Undertow 鑷畾涔夐厤缃�
@@ -24,12 +26,12 @@
             WebSocketDeploymentInfo webSocketDeploymentInfo = new WebSocketDeploymentInfo();
             webSocketDeploymentInfo.setBuffers(new DefaultByteBufferPool(false, 512));
             deploymentInfo.addServletContextAttribute("io.undertow.websockets.jsr.WebSocketDeploymentInfo", webSocketDeploymentInfo);
-            // 浣跨敤铏氭嫙绾跨▼ 瑙i櫎涓嬫柟娉ㄩ噴 浠呴檺jdk21
-//            if (SpringUtils.isVirtual()) {
-//                VirtualThreadTaskExecutor executor = new VirtualThreadTaskExecutor("undertow-");
-//                deploymentInfo.setExecutor(executor);
-//                deploymentInfo.setAsyncExecutor(executor);
-//            }
+            // 浣跨敤铏氭嫙绾跨▼
+            if (SpringUtils.isVirtual()) {
+                VirtualThreadTaskExecutor executor = new VirtualThreadTaskExecutor("undertow-");
+                deploymentInfo.setExecutor(executor);
+                deploymentInfo.setAsyncExecutor(executor);
+            }
         });
     }
 

--
Gitblit v1.9.3