From fa1421b5f1834be8b09bf75f389d09b63a3f1a43 Mon Sep 17 00:00:00 2001 From: theonefx Date: Thu, 26 Mar 2020 00:07:15 +0800 Subject: [PATCH 1/2] fix: https://github.com/alibaba/nacos/issues/2527 --- .../com/alibaba/nacos/client/naming/net/NamingProxy.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java b/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java index f196443db6e..c32b216e1d5 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java @@ -48,7 +48,9 @@ import java.io.IOException; import java.io.StringReader; +import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; +import java.net.URLEncoder; import java.util.*; import java.util.concurrent.*; @@ -327,7 +329,11 @@ public JSONObject sendBeat(BeatInfo beatInfo, boolean lightBeatEnabled) throws N Map params = new HashMap(8); String body = StringUtils.EMPTY; if (!lightBeatEnabled) { - body = "beat=" + JSON.toJSONString(beatInfo); + try { + body = "beat=" + URLEncoder.encode(JSON.toJSONString(beatInfo), "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new NacosException(NacosException.SERVER_ERROR, "encod beatInfo error", e); + } } params.put(CommonParams.NAMESPACE_ID, namespaceId); params.put(CommonParams.SERVICE_NAME, beatInfo.getServiceName()); From bebea333f50a39b1b1707a2a94b1989126884291 Mon Sep 17 00:00:00 2001 From: theonefx Date: Thu, 26 Mar 2020 10:55:44 +0800 Subject: [PATCH 2/2] spelling mistake --- .../java/com/alibaba/nacos/client/naming/net/NamingProxy.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java b/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java index c32b216e1d5..8a91e965ae8 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java @@ -332,7 +332,7 @@ public JSONObject sendBeat(BeatInfo beatInfo, boolean lightBeatEnabled) throws N try { body = "beat=" + URLEncoder.encode(JSON.toJSONString(beatInfo), "UTF-8"); } catch (UnsupportedEncodingException e) { - throw new NacosException(NacosException.SERVER_ERROR, "encod beatInfo error", e); + throw new NacosException(NacosException.SERVER_ERROR, "encode beatInfo error", e); } } params.put(CommonParams.NAMESPACE_ID, namespaceId);