From c277d2a438a15e504513e7abdbd220b54e0d476d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E6=99=B4=E9=A3=8E?= <1397649957@qq.com> Date: Mon, 25 May 2020 17:18:05 +0800 Subject: [PATCH] code optimize --- .../nacos/naming/core/ServiceManager.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java b/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java index 6e59df26c21..6fdc5638eb6 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java @@ -308,17 +308,15 @@ public void updatedHealthStatus(String namespaceId, String serviceName, String s if (changed) { pushService.serviceChanged(service); - } - - StringBuilder stringBuilder = new StringBuilder(); - List allIps = service.allIPs(); - for (Instance instance : allIps) { - stringBuilder.append(instance.toIPAddr()).append("_").append(instance.isHealthy()).append(","); - } - - if (changed && Loggers.EVT_LOG.isDebugEnabled()) { - Loggers.EVT_LOG.debug("[HEALTH-STATUS-UPDATED] namespace: {}, service: {}, ips: {}", - service.getNamespaceId(), service.getName(), stringBuilder.toString()); + if (Loggers.EVT_LOG.isDebugEnabled()){ + StringBuilder stringBuilder = new StringBuilder(); + List allIps = service.allIPs(); + for (Instance instance : allIps) { + stringBuilder.append(instance.toIPAddr()).append("_").append(instance.isHealthy()).append(","); + } + Loggers.EVT_LOG.debug("[HEALTH-STATUS-UPDATED] namespace: {}, service: {}, ips: {}", + service.getNamespaceId(), service.getName(), stringBuilder.toString()); + } } }