From b6f02b6adcfcdd1f56363de87f2590cfdbad2b36 Mon Sep 17 00:00:00 2001 From: pizihao <2335715300@qq.com> Date: Mon, 5 Sep 2022 15:37:49 +0800 Subject: [PATCH] fix: Change check order and The first line indentation (#614) --- .../starter/refresher/event/AbstractRefreshListener.java | 8 ++++---- .../refresher/event/AdapterExecutorsRefreshListener.java | 2 +- .../refresher/event/DynamicThreadPoolRefreshListener.java | 5 ++++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/AbstractRefreshListener.java b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/AbstractRefreshListener.java index b73bac01..051a61f8 100644 --- a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/AbstractRefreshListener.java +++ b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/AbstractRefreshListener.java @@ -95,10 +95,10 @@ public abstract class AbstractRefreshListener implements RefreshListener i.check(ipSegment, port)); + .distinct() + .map(IpAndPort::build) + .filter(Objects::nonNull) + .anyMatch(i -> i.check(ipSegment, port)); } /** diff --git a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/AdapterExecutorsRefreshListener.java b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/AdapterExecutorsRefreshListener.java index b7108f6d..09838838 100644 --- a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/AdapterExecutorsRefreshListener.java +++ b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/AdapterExecutorsRefreshListener.java @@ -61,7 +61,7 @@ public class AdapterExecutorsRefreshListener extends AbstractRefreshListener { if (Objects.equals(val.mark(), each.getMark())) { val.updateThreadPool(BeanUtil.toBean(each, ThreadPoolAdapterParameter.class)); diff --git a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/DynamicThreadPoolRefreshListener.java b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/DynamicThreadPoolRefreshListener.java index 915c4225..ec93577c 100644 --- a/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/DynamicThreadPoolRefreshListener.java +++ b/hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/refresher/event/DynamicThreadPoolRefreshListener.java @@ -79,13 +79,16 @@ public class DynamicThreadPoolRefreshListener extends AbstractRefreshListener executors = bindableConfigProperties.getExecutors(); for (ExecutorProperties properties : executors) { String threadPoolId = properties.getThreadPoolId(); - if (!match(properties) || !checkConsistency(threadPoolId, properties)) { + if (!match(properties)) { continue; } /* * Check whether the notification configuration is consistent, this operation will not trigger the notification. */ checkNotifyConsistencyAndReplace(properties); + if (!checkConsistency(threadPoolId, properties)) { + continue; + } dynamicRefreshPool(threadPoolId, properties); ExecutorProperties beforeProperties = GlobalCoreThreadPoolManage.getProperties(properties.getThreadPoolId()); GlobalCoreThreadPoolManage.refresh(threadPoolId, failDefaultExecutorProperties(beforeProperties, properties));