Closed ljee-hash closed 6 years ago
Can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.
thank you very much! I have solve the issues,it's my fault.
String responseBody = CharStreams.toString(new InputStreamReader(context.getResponseDataStream()));
String responseBody = IOUtils.toString(context.getResponseDataStream());// replaced by IOUtils.copy(writer,inputStream)
the two ways is not thread safe ! I forget it!
I solved it by rewriting the synchronous Writer method.But I don't know why asynchronous methods cause problems.
if(context.getRequest() != null){
Map<String,Object> resultMap = new LinkedHashMap<>();
HttpServletRequest request = context.getRequest();
String callback = request.getParameter("callback");
if (context.getResponseStatusCode() == HttpStatus.SC_OK) {
// String responseBody = CharStreams.toString(new InputStreamReader(context.getResponseDataStream()));
String responseBody = IOUtils.toString(context.getResponseDataStream());
resultMap = JSON.parseObject(responseBody, LinkedHashMap.class);
}
if(resultMap != null && resultMap.size() > 0){
resultMap.put("ret",context.getResponseStatusCode());
if (StringUtils.isNotEmpty(callback)) {
StringBuffer buf = new StringBuffer();
buf.append(callback);
buf.append("(");
buf.append(JsonUtil.toJSON(resultMap));
buf.append(")");
is = new ByteArrayInputStream(buf.toString().getBytes(StandardCharsets.UTF_8));
}
}
}
I use zuul send request the response is waitting ,
I have rewrited the SendResponseFilter ,because in my project I want do cache and convert result to JSON and JsonP .
by analysis the dump , I got the error !
the application.properties