From 8055985df4f80e6ee7a1345b4f0821ffa2871173 Mon Sep 17 00:00:00 2001 From: wolfdriver Date: Sun, 29 Mar 2020 22:54:33 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/alibaba/nacos/client/config/NacosConfigService.java | 2 -- .../alibaba/nacos/client/config/http/MetricsHttpAgent.java | 6 +++--- .../client/config/impl/AbstractConfigChangeParser.java | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) 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 c25f557c2..f8dd1eb4a 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 @@ -55,8 +55,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; From c99ac322afe9ccbe5eba4e4af6e8753288b4f97b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 23 Apr 2020 17:52:58 +0000 Subject: [PATCH 2/5] build(deps): bump jackson-databind from 2.9.10.3 to 2.9.10.4 Bumps [jackson-databind](https://github.com/FasterXML/jackson) from 2.9.10.3 to 2.9.10.4. - [Release notes](https://github.com/FasterXML/jackson/releases) - [Commits](https://github.com/FasterXML/jackson/commits) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 920f076fa..37d2fb91f 100644 --- a/pom.xml +++ b/pom.xml @@ -691,7 +691,7 @@ com.fasterxml.jackson.core jackson-databind - 2.9.10.3 + 2.9.10.4 org.codehaus.jackson From 3c195377d651d73b510236893fbce875f656c3b8 Mon Sep 17 00:00:00 2001 From: "mai.jh" Date: Sun, 26 Apr 2020 11:22:47 +0800 Subject: [PATCH 3/5] Modify log output --- .../com/alibaba/nacos/client/config/impl/ClientWorker.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 f17ddccb3..060653641 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.client.config.utils.MD5; 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); From 2b10aebb76457ce79fd54c4ca196bbc08e8d2ea9 Mon Sep 17 00:00:00 2001 From: jiangcaijun Date: Sun, 26 Apr 2020 17:19:18 +0800 Subject: [PATCH 4/5] hashMap constructor : choose more appropriate initialCapacity --- .../alibaba/nacos/naming/misc/ServiceStatusSynchronizer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1897a59ab..0494a2151 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); From 071be5c3d40909fcf437667e42e71a998ef16f1a Mon Sep 17 00:00:00 2001 From: wanyuyichen Date: Thu, 7 May 2020 17:19:58 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=94=B1=E4=BA=8EControl?= =?UTF-8?q?lerMethodsCache=E7=B1=BB=E7=9A=84getMethod=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E4=B8=AD=EF=BC=8C=E7=94=B1=E4=BA=8Ereplace=20target=E5=86=99?= =?UTF-8?q?=E6=AD=BB=E9=80=A0=E6=88=90=E7=9A=84=E4=BF=AE=E6=94=B9contextPa?= =?UTF-8?q?th=E5=90=8E=E6=89=BE=E4=B8=8D=E5=88=B0api=E7=9A=84=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/alibaba/nacos/core/code/ControllerMethodsCache.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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); }