From 1863431ead5e555eaedc944a6d1ce862b269cca1 Mon Sep 17 00:00:00 2001 From: JermaineHua Date: Wed, 25 Sep 2024 15:41:41 +0800 Subject: [PATCH] Fix threadpool monitor when using virtual thread 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()); + } } } }