From d285ec453516b78af11e0605658f824e178de635 Mon Sep 17 00:00:00 2001 From: Jermaine Hua Date: Wed, 25 Sep 2024 16:04:32 +0800 Subject: [PATCH] Fix threadpool monitor when using virtual thread (#1344) Signed-off-by: JermaineHua --- .../rpc/boot/container/ServerConfigContainer.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/main/java/com/alipay/sofa/rpc/boot/container/ServerConfigContainer.java b/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/main/java/com/alipay/sofa/rpc/boot/container/ServerConfigContainer.java index 5f6ac49ec..539dc2d70 100644 --- a/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/main/java/com/alipay/sofa/rpc/boot/container/ServerConfigContainer.java +++ b/sofa-boot-project/sofa-boot-core/rpc-sofa-boot/src/main/java/com/alipay/sofa/rpc/boot/container/ServerConfigContainer.java @@ -40,6 +40,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Executor; import java.util.concurrent.ThreadPoolExecutor; /** @@ -275,9 +276,14 @@ private void startCustomThreadPoolMonitor() { } else { customThreadPoolMonitor.setPoolName(pool.getThreadPoolName()); } - customThreadPoolMonitor.setThreadPoolExecutor(pool.getExecutor()); - customThreadPoolMonitor.start(); - poolNames.add(pool.getThreadPoolName()); + + Executor tmp = pool.getUserExecutor(); + if (tmp instanceof ThreadPoolExecutor) { + customThreadPoolMonitor.setThreadPoolExecutor((ThreadPoolExecutor) pool + .getUserExecutor()); + customThreadPoolMonitor.start(); + poolNames.add(pool.getThreadPoolName()); + } } } }