From 68f170c9300250ca4a29e8ae97a624d0f5170e7a Mon Sep 17 00:00:00 2001 From: pbting <314226532@qq.com> Date: Fri, 9 Aug 2019 12:15:05 +0800 Subject: [PATCH] repair httpGetLarge#httpGetLarge will call entity.getContentType().getElements() the contentType is NPE --- .../alibaba/nacos/naming/controllers/DistroController.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/DistroController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/DistroController.java index e74024710..b810fc52c 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/DistroController.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/DistroController.java @@ -32,6 +32,7 @@ import com.alibaba.nacos.naming.misc.UtilsAndCommons; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @@ -106,7 +107,7 @@ public class DistroController { } @RequestMapping(value = "/datum", method = RequestMethod.GET) - public void get(HttpServletRequest request, HttpServletResponse response) throws Exception { + public ResponseEntity get(HttpServletRequest request, HttpServletResponse response) throws Exception { String entity = IOUtils.toString(request.getInputStream(), "UTF-8"); String keys = JSON.parseObject(entity).getString("keys"); @@ -119,7 +120,9 @@ public class DistroController { } datumMap.put(key, datum); } - response.getWriter().write(new String(serializer.serialize(datumMap), StandardCharsets.UTF_8)); + + String content = new String(serializer.serialize(datumMap), StandardCharsets.UTF_8); + return ResponseEntity.ok(content); } @RequestMapping(value = "/datums", method = RequestMethod.GET)