From 3f8df895e0292aef2d7f18e392e012807c63c1ce Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Wed, 27 Oct 2021 23:27:21 +0800 Subject: [PATCH] =?UTF-8?q?optimize:=20=E7=BA=BF=E7=A8=8B=E6=B1=A0?= =?UTF-8?q?=E6=9E=84=E9=80=A0=E5=99=A8=E5=88=9B=E5=BB=BA=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E7=BA=BF=E7=A8=8B=E6=B1=A0,=20=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E6=B1=A0=E6=A0=87=E8=AF=86=E9=BB=98=E8=AE=A4=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E5=B7=A5=E5=8E=82=E5=89=8D=E7=BC=80,=20=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=B5=81=E7=A8=8B.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../threadpool/starter/toolkit/thread/ThreadPoolBuilder.java | 4 +++- .../dynamic/threadpool/example/config/ThreadPoolConfig.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/ThreadPoolBuilder.java b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/ThreadPoolBuilder.java index 775daca6..134f662a 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/ThreadPoolBuilder.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/com/github/dynamic/threadpool/starter/toolkit/thread/ThreadPoolBuilder.java @@ -5,6 +5,7 @@ import com.github.dynamic.threadpool.common.toolkit.Assert; import com.github.dynamic.threadpool.starter.alarm.ThreadPoolAlarm; import java.math.BigDecimal; +import java.util.Optional; import java.util.concurrent.*; /** @@ -267,7 +268,8 @@ public class ThreadPoolBuilder implements Builder { .setTimeUnit(builder.timeUnit); if (builder.isCustomPool) { - initParam.setThreadPoolId(builder.threadPoolId); + String threadPoolId = Optional.ofNullable(builder.threadPoolId).orElse(builder.threadNamePrefix); + initParam.setThreadPoolId(threadPoolId); ThreadPoolAlarm threadPoolAlarm = new ThreadPoolAlarm(builder.isAlarm, builder.capacityAlarm, builder.livenessAlarm); initParam.setThreadPoolAlarm(threadPoolAlarm); } diff --git a/example/src/main/java/com/github/dynamic/threadpool/example/config/ThreadPoolConfig.java b/example/src/main/java/com/github/dynamic/threadpool/example/config/ThreadPoolConfig.java index c372f32a..6d3ec6c6 100644 --- a/example/src/main/java/com/github/dynamic/threadpool/example/config/ThreadPoolConfig.java +++ b/example/src/main/java/com/github/dynamic/threadpool/example/config/ThreadPoolConfig.java @@ -42,7 +42,7 @@ public class ThreadPoolConfig { @Bean @DynamicThreadPool public ThreadPoolExecutor customThreadPoolExecutor() { - return ThreadPoolBuilder.builder().threadFactory(MESSAGE_PRODUCE).threadPoolId(MESSAGE_PRODUCE).isCustomPool(true).build(); + return ThreadPoolBuilder.builder().threadFactory(MESSAGE_PRODUCE).isCustomPool(true).build(); } }