简体   繁体   English

Feign Client Get Request HttpStatus 200 but body is null when json is very long

[英]Feign Client Get Request HttpStatus 200 but body is null when json is very long

I have an issue with my Feign client, I get the response as well when the json not containing lot of data.我的 Feign 客户端有问题,当 json 不包含大量数据时,我也会得到响应。 But when a json is very long I get 200 status inside Response Object but body is null:但是当 json 很长时,我在响应Object 中获得 200 状态,但正文是 null:

@FeignClient(name = "processSvc", url = "${xxx}")
public interface ProcessClient {

  
    @GetMapping(value = "/v1/process/{uid}", produces = "application/json")
    Response readProcess(@PathVariable("uid") String uid);
}

Any proposition for resolve this issue?有解决这个问题的建议吗?

The issue was reading a response that is larger than the entire memory allocated to the current process.问题是读取的响应大于分配给当前进程的整个 memory。 So, streaming the response fixed the issue by getting the body as InputStream, then convert it to String via IOUtils.toString():因此,流式传输响应通过将正文作为 InputStream 来解决问题,然后通过 IOUtils.toString() 将其转换为字符串:

Response response = null;
        String json;
        try {
             response = processClient.readProcess(uid);
             json = IOUtils.toString(response.body().asInputStream(), Charsets.UTF_8.name());
        } catch (IOException e) {
                throw new RuntimeException(e);
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Feign Client + Eureka POST请求正文 - Feign Client + Eureka POST request body 我如何从假冒的客户请求中获得经过的时间? - How can I get the elapsed time from a feign client request? 为什么得到200的响应但没有在使用KAA的端点客户端中显示消息正文 - Why get a response of 200 but not showing message body in the endpoint client with KAA 将 feign 客户端的响应正文解码为 MyObject - Decode response body from feign client to MyObject 使用Jersey客户端向请求正文获取OuputStream? - Get an OuputStream to a request body using Jersey Client? 使用非常长的查询字符串获取请求。 (CSV) - Get request with very long query string. (CSV) Feign REST客户端:如何获取HTTP状态? - Feign REST Client: How to get the HTTP status? Failed to parse the JSON document: Request successful return 200 response but response body isn't printed in Log 文件 - Failed to parse the JSON document: Request successfully return 200 response but response body isn't printed in Log file 如果客户端设置 content-type="application/xml" 并且 body=null,如何解析 POST 请求的请求正文? - How to parse request body of POST request, if client set content-type="application/xml" and body=null? 在 spring 中调用 retrofit 状态码不为 200 时响应体为 null - Response body is null when status code is not 200 while making a retrofit call in spring
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM