From 0d18347063294a2ed872a85194550cd6be699c5c Mon Sep 17 00:00:00 2001 From: MengJinLong <1023149936@qq.com> Date: Sat, 18 Nov 2023 21:35:18 +0800 Subject: [PATCH] Optimization value equality comparison method. --- .../refresher/event/DynamicThreadPoolRefreshListener.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/starters/threadpool/config/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/DynamicThreadPoolRefreshListener.java b/starters/threadpool/config/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/DynamicThreadPoolRefreshListener.java index 25bb91e6f5..94ac40c9a9 100644 --- a/starters/threadpool/config/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/DynamicThreadPoolRefreshListener.java +++ b/starters/threadpool/config/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/DynamicThreadPoolRefreshListener.java @@ -194,10 +194,9 @@ private void checkNotifyConsistencyAndReplace(ExecutorProperties executorPropert Boolean isAlarm = executorProperties.getAlarm(); Integer activeAlarm = executorProperties.getActiveAlarm(); Integer capacityAlarm = executorProperties.getCapacityAlarm(); - // FIXME Compare using Objects.equals - if ((isAlarm != null && isAlarm != threadPoolNotifyAlarm.getAlarm()) - || (activeAlarm != null && activeAlarm != threadPoolNotifyAlarm.getActiveAlarm()) - || (capacityAlarm != null && capacityAlarm != threadPoolNotifyAlarm.getCapacityAlarm())) { + if ((isAlarm != null && !Objects.equals(isAlarm,threadPoolNotifyAlarm.getAlarm())) + || (activeAlarm != null && !Objects.equals(activeAlarm,threadPoolNotifyAlarm.getActiveAlarm())) + || (capacityAlarm != null && !Objects.equals(capacityAlarm,threadPoolNotifyAlarm.getCapacityAlarm()))) { checkNotifyAlarm = true; threadPoolNotifyAlarm.setAlarm(Optional.ofNullable(isAlarm).orElse(threadPoolNotifyAlarm.getAlarm())); threadPoolNotifyAlarm.setActiveAlarm(Optional.ofNullable(activeAlarm).orElse(threadPoolNotifyAlarm.getActiveAlarm()));