From ae59e5dd3bd8138385a81f80053f85267652c13b Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Tue, 27 Jul 2021 22:13:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E6=B1=A0=E9=80=BB=E8=BE=91.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../threadpool/starter/core/ThreadPoolRunListener.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/core/ThreadPoolRunListener.java b/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/core/ThreadPoolRunListener.java index 721c38e0..ec56f50d 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/core/ThreadPoolRunListener.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/core/ThreadPoolRunListener.java @@ -52,6 +52,7 @@ public class ThreadPoolRunListener { PoolParameterInfo ppi = new PoolParameterInfo(); HttpAgent httpAgent = new ServerHttpAgent(properties); + ThreadPoolExecutor poolExecutor = null; Result result = null; try { @@ -59,7 +60,7 @@ public class ThreadPoolRunListener { if (result.isSuccess() && result.getData() != null && (ppi = JSON.toJavaObject((JSON) result.getData(), PoolParameterInfo.class)) != null) { // 使用相关参数创建线程池 BlockingQueue workQueue = QueueTypeEnum.createBlockingQueue(ppi.getQueueType(), ppi.getCapacity()); - ThreadPoolExecutor poolExecutor = ThreadPoolBuilder.builder() + poolExecutor = ThreadPoolBuilder.builder() .isCustomPool(true) .poolThreadSize(ppi.getCoreSize(), ppi.getMaxSize()) .keepAliveTime(ppi.getKeepAliveTime(), TimeUnit.SECONDS) @@ -73,8 +74,10 @@ public class ThreadPoolRunListener { val.setPool(CommonThreadPool.getInstance(tpId)); } } catch (Exception ex) { + poolExecutor = val.getPool() != null ? val.getPool() : CommonThreadPool.getInstance(tpId); + val.setPool(poolExecutor); + log.error("[Init pool] Failed to initialize thread pool configuration. error message :: {}", ex.getMessage()); - val.setPool(CommonThreadPool.getInstance(tpId)); } GlobalThreadPoolManage.register(val.getTpId(), ppi, val);