1. executeTimeOut配置项或考虑可选,默认设置0不使用,目前不配置将导致NPE;2. 增加错误输出信息,NullPointException无堆栈信息不好排查

pull/135/head
LinJinYi 3 years ago
parent 80d4ee936d
commit 7e800b31dc

@ -18,6 +18,7 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.task.TaskDecorator;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@ -102,7 +103,7 @@ public final class DynamicThreadPoolPostProcessor implements BeanPostProcessor {
.dynamicPool()
.workQueue(workQueue)
.threadFactory(threadPoolId)
.executeTimeOut(executorProperties.getExecuteTimeOut())
.executeTimeOut(Optional.ofNullable(executorProperties.getExecuteTimeOut()).orElse(0L))
.poolThreadSize(executorProperties.getCorePoolSize(), executorProperties.getMaximumPoolSize())
.keepAliveTime(executorProperties.getKeepAliveTime(), TimeUnit.SECONDS)
.rejected(RejectedTypeEnum.createPolicy(executorProperties.getRejectedHandler()))
@ -132,7 +133,7 @@ public final class DynamicThreadPoolPostProcessor implements BeanPostProcessor {
dynamicThreadPoolWrap.setExecutor(newDynamicPoolExecutor);
} catch (Exception ex) {
log.error("Failed to initialize thread pool configuration. error message :: {}", ex.getMessage());
log.error("Failed to initialize thread pool configuration. error :: {}", ex);
} finally {
if (Objects.isNull(dynamicThreadPoolWrap.getExecutor())) {
dynamicThreadPoolWrap.setExecutor(CommonDynamicThreadPool.getInstance(threadPoolId));

Loading…
Cancel
Save