From 062df6b2d66b096315a87fecf2c9d556ba97780b Mon Sep 17 00:00:00 2001 From: shanjianq <49084314+shanjianq@users.noreply.github.com> Date: Wed, 7 Sep 2022 14:20:51 +0800 Subject: [PATCH] remove useless temporary variables in DynamicThreadPoolPostProcessor (#676) --- .../support/DynamicThreadPoolPostProcessor.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/support/DynamicThreadPoolPostProcessor.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/support/DynamicThreadPoolPostProcessor.java index fe80b71b..bbabf6bc 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/support/DynamicThreadPoolPostProcessor.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/support/DynamicThreadPoolPostProcessor.java @@ -153,20 +153,19 @@ public final class DynamicThreadPoolPostProcessor implements BeanPostProcessor { .allowCoreThreadTimeOut(EnableEnum.getBool(threadPoolParameterInfo.getAllowCoreThreadTimeOut())) .build(); // Set dynamic thread pool enhancement parameters. - ThreadPoolExecutor customDynamicThreadPool; - if ((customDynamicThreadPool = executor) instanceof AbstractDynamicExecutorSupport) { + if (executor instanceof AbstractDynamicExecutorSupport) { ThreadPoolNotifyAlarm threadPoolNotifyAlarm = new ThreadPoolNotifyAlarm( BooleanUtil.toBoolean(threadPoolParameterInfo.getIsAlarm().toString()), threadPoolParameterInfo.getCapacityAlarm(), threadPoolParameterInfo.getLivenessAlarm()); GlobalNotifyAlarmManage.put(threadPoolId, threadPoolNotifyAlarm); - TaskDecorator taskDecorator = ((DynamicThreadPoolExecutor) customDynamicThreadPool).getTaskDecorator(); + TaskDecorator taskDecorator = ((DynamicThreadPoolExecutor) executor).getTaskDecorator(); ((DynamicThreadPoolExecutor) newDynamicThreadPoolExecutor).setTaskDecorator(taskDecorator); - long awaitTerminationMillis = ((DynamicThreadPoolExecutor) customDynamicThreadPool).awaitTerminationMillis; - boolean waitForTasksToCompleteOnShutdown = ((DynamicThreadPoolExecutor) customDynamicThreadPool).waitForTasksToCompleteOnShutdown; + long awaitTerminationMillis = ((DynamicThreadPoolExecutor) executor).awaitTerminationMillis; + boolean waitForTasksToCompleteOnShutdown = ((DynamicThreadPoolExecutor) executor).waitForTasksToCompleteOnShutdown; ((DynamicThreadPoolExecutor) newDynamicThreadPoolExecutor).setSupportParam(awaitTerminationMillis, waitForTasksToCompleteOnShutdown); long executeTimeOut = Optional.ofNullable(threadPoolParameterInfo.getExecuteTimeOut()) - .orElse(((DynamicThreadPoolExecutor) customDynamicThreadPool).getExecuteTimeOut()); + .orElse(((DynamicThreadPoolExecutor) executor).getExecuteTimeOut()); ((DynamicThreadPoolExecutor) newDynamicThreadPoolExecutor).setExecuteTimeOut(executeTimeOut); } dynamicThreadPoolWrapper.setExecutor(newDynamicThreadPoolExecutor);