diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/ServiceController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/ServiceController.java index d4bec7771..878d2a405 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/ServiceController.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/ServiceController.java @@ -31,6 +31,7 @@ import com.alibaba.nacos.naming.misc.UtilsAndCommons; import com.alibaba.nacos.naming.selector.LabelSelector; import com.alibaba.nacos.naming.selector.NoneSelector; import com.alibaba.nacos.naming.selector.Selector; +import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -39,6 +40,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; +import java.io.IOException; import java.net.URLDecoder; import java.util.*; @@ -299,10 +301,15 @@ public class ServiceController { } @RequestMapping(value = "/status", method = RequestMethod.POST) - public String serviceStatus(HttpServletRequest request) { + public String serviceStatus(HttpServletRequest request) throws IOException { + + String entity = IOUtils.toString(request.getInputStream(), "UTF-8"); + String value = URLDecoder.decode(entity, "UTF-8"); + JSONObject json = JSON.parseObject(value); + //format: service1@@checksum@@@service2@@checksum - String statuses = WebUtils.required(request, "statuses"); - String serverIP = WebUtils.optional(request, "clientIP", ""); + String statuses = json.getString("statuses"); + String serverIP = json.getString("clientIP"); if (!serverListManager.contains(serverIP)) { throw new IllegalArgumentException("ip: " + serverIP + " is not in serverlist"); diff --git a/naming/src/main/java/com/alibaba/nacos/naming/core/Instances.java b/naming/src/main/java/com/alibaba/nacos/naming/core/Instances.java index 57752790e..933a7ea88 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/core/Instances.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/core/Instances.java @@ -25,6 +25,7 @@ import java.math.BigInteger; import java.nio.charset.Charset; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -40,7 +41,7 @@ public class Instances implements Record { private long lastCalculateTime = 0L; - private List instanceList; + private List instanceList = new ArrayList<>(); public List getInstanceList() { return instanceList; 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 4cfa285fc..8c6ddc8c9 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 @@ -15,6 +15,7 @@ */ package com.alibaba.nacos.naming.misc; +import com.alibaba.fastjson.JSON; import com.alibaba.nacos.naming.boot.RunningConfig; import com.ning.http.client.AsyncCompletionHandler; import com.ning.http.client.Response; @@ -49,7 +50,7 @@ public class ServiceStatusSynchronizer implements Synchronizer { } try { - HttpClient.asyncHttpPost(url, null, params, new AsyncCompletionHandler() { + HttpClient.asyncHttpPostLarge(url, null, JSON.toJSONString(params), new AsyncCompletionHandler() { @Override public Integer onCompleted(Response response) throws Exception { if (response.getStatusCode() != HttpURLConnection.HTTP_OK) {