diff --git a/client/src/main/java/com/alibaba/nacos/client/config/NacosConfigService.java b/client/src/main/java/com/alibaba/nacos/client/config/NacosConfigService.java index ff3da8855..4c5a82e38 100644 --- a/client/src/main/java/com/alibaba/nacos/client/config/NacosConfigService.java +++ b/client/src/main/java/com/alibaba/nacos/client/config/NacosConfigService.java @@ -56,8 +56,6 @@ public class NacosConfigService implements ConfigService { private static final long POST_TIMEOUT = 3000L; - private static final String EMPTY = ""; - /** * http agent */ diff --git a/client/src/main/java/com/alibaba/nacos/client/config/http/MetricsHttpAgent.java b/client/src/main/java/com/alibaba/nacos/client/config/http/MetricsHttpAgent.java index 21b6654bd..2449c4131 100644 --- a/client/src/main/java/com/alibaba/nacos/client/config/http/MetricsHttpAgent.java +++ b/client/src/main/java/com/alibaba/nacos/client/config/http/MetricsHttpAgent.java @@ -43,7 +43,7 @@ public class MetricsHttpAgent implements HttpAgent { @Override public HttpResult httpGet(String path, List headers, List paramValues, String encoding, long readTimeoutMs) throws IOException { Histogram.Timer timer = MetricsMonitor.getConfigRequestMonitor("GET", path, "NA"); - HttpResult result = null; + HttpResult result; try { result = httpAgent.httpGet(path, headers, paramValues, encoding, readTimeoutMs); } catch (IOException e) { @@ -59,7 +59,7 @@ public class MetricsHttpAgent implements HttpAgent { @Override public HttpResult httpPost(String path, List headers, List paramValues, String encoding, long readTimeoutMs) throws IOException { Histogram.Timer timer = MetricsMonitor.getConfigRequestMonitor("POST", path, "NA"); - HttpResult result = null; + HttpResult result; try { result = httpAgent.httpPost(path, headers, paramValues, encoding, readTimeoutMs); } catch (IOException e) { @@ -75,7 +75,7 @@ public class MetricsHttpAgent implements HttpAgent { @Override public HttpResult httpDelete(String path, List headers, List paramValues, String encoding, long readTimeoutMs) throws IOException { Histogram.Timer timer = MetricsMonitor.getConfigRequestMonitor("DELETE", path, "NA"); - HttpResult result = null; + HttpResult result; try { result = httpAgent.httpDelete(path, headers, paramValues, encoding, readTimeoutMs); } catch (IOException e) { diff --git a/client/src/main/java/com/alibaba/nacos/client/config/impl/AbstractConfigChangeParser.java b/client/src/main/java/com/alibaba/nacos/client/config/impl/AbstractConfigChangeParser.java index bea9e6d52..a6457385e 100644 --- a/client/src/main/java/com/alibaba/nacos/client/config/impl/AbstractConfigChangeParser.java +++ b/client/src/main/java/com/alibaba/nacos/client/config/impl/AbstractConfigChangeParser.java @@ -44,7 +44,7 @@ public abstract class AbstractConfigChangeParser implements ConfigChangeParser { Map result = new HashMap(16); for (Iterator> entryItr = oldMap.entrySet().iterator(); entryItr.hasNext();) { Map.Entry e = entryItr.next(); - ConfigChangeItem cci = null; + ConfigChangeItem cci; if (newMap.containsKey(e.getKey())) { if (e.getValue().equals(newMap.get(e.getKey()))) { continue; diff --git a/client/src/main/java/com/alibaba/nacos/client/config/impl/ClientWorker.java b/client/src/main/java/com/alibaba/nacos/client/config/impl/ClientWorker.java index 10c12d7fc..9218eb2fc 100644 --- a/client/src/main/java/com/alibaba/nacos/client/config/impl/ClientWorker.java +++ b/client/src/main/java/com/alibaba/nacos/client/config/impl/ClientWorker.java @@ -27,6 +27,7 @@ import com.alibaba.nacos.client.config.impl.HttpSimpleClient.HttpResult; import com.alibaba.nacos.client.config.utils.ContentUtils; import com.alibaba.nacos.common.utils.MD5Utils; import com.alibaba.nacos.client.monitor.MetricsMonitor; +import com.alibaba.nacos.client.naming.utils.CollectionUtils; import com.alibaba.nacos.client.utils.LogUtils; import com.alibaba.nacos.client.utils.ParamUtil; import com.alibaba.nacos.client.utils.TenantUtil; @@ -519,7 +520,10 @@ public class ClientWorker { // check server config List changedGroupKeys = checkUpdateDataIds(cacheDatas, inInitializingCacheList); - LOGGER.info("get changedGroupKeys:" + changedGroupKeys); + if (!CollectionUtils.isEmpty(changedGroupKeys)) { + LOGGER.info("get changedGroupKeys:" + changedGroupKeys); + } + for (String groupKey : changedGroupKeys) { String[] key = GroupKey.parseKey(groupKey); diff --git a/core/src/main/java/com/alibaba/nacos/core/code/ControllerMethodsCache.java b/core/src/main/java/com/alibaba/nacos/core/code/ControllerMethodsCache.java index 97dc9bfca..7c4ea9d77 100644 --- a/core/src/main/java/com/alibaba/nacos/core/code/ControllerMethodsCache.java +++ b/core/src/main/java/com/alibaba/nacos/core/code/ControllerMethodsCache.java @@ -18,6 +18,7 @@ package com.alibaba.nacos.core.code; import org.apache.commons.lang3.ArrayUtils; import org.reflections.Reflections; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.*; @@ -35,6 +36,9 @@ import java.util.concurrent.ConcurrentMap; @Component public class ControllerMethodsCache { + @Value("${server.servlet.contextPath:/nacos}") + private String contextPath; + private ConcurrentMap methods = new ConcurrentHashMap<>(); @@ -43,7 +47,7 @@ public class ControllerMethodsCache { } public Method getMethod(String httpMethod, String path) { - String key = httpMethod + "-->" + path.replace("/nacos", ""); + String key = httpMethod + "-->" + path.replace(contextPath, ""); return methods.get(key); } diff --git a/naming/src/main/java/com/alibaba/nacos/naming/misc/ServiceStatusSynchronizer.java b/naming/src/main/java/com/alibaba/nacos/naming/misc/ServiceStatusSynchronizer.java index 5d40e011c..323ad3a6e 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/misc/ServiceStatusSynchronizer.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/misc/ServiceStatusSynchronizer.java @@ -73,7 +73,7 @@ public class ServiceStatusSynchronizer implements Synchronizer { return null; } - Map params = new HashMap<>(10); + Map params = new HashMap<>(1); params.put("key", key); diff --git a/pom.xml b/pom.xml index 92199bddd..15d8ceb5f 100644 --- a/pom.xml +++ b/pom.xml @@ -786,7 +786,7 @@ com.fasterxml.jackson.core jackson-databind - 2.9.10.3 + 2.9.10.4 org.codehaus.jackson