I have a rest service and is consumed using Spring's RestTemplate with Apache HttpClient as,
@Autowired
public ClientImpl(@Value("${base-uri}") final String baseUrl,
@Qualifier("restOperations") RestOperations restTemplate) {
serviceUrl = baseUrl;
restTemplate = restTemplate;
}
private List<ResponseDetails> processRequest(CustomRequest request) throws Exception {
ResponseEntity<ResponseDetails[]> responseEntity = restTemplate.exchange(serviceUrl, HttpMethod.POST, entity, ResponseDetails[].class);
if (responseEntity.getStatusCode().value() == 204) {
return Collections.<ResponseDetails>emptyList();
}
ResponseDetails[] response = responseEntity.getBody();
return response != null ? Lists.newArrayList(response) : Collections.<ResponseDetails>emptyList();
}
When the webservice returns 204 response, then the second service call after 204 response, fails with read timeout.
Spring-web : 4.3.5
I cannot figure out the cause. Any help?
EDIT: From debug logs,
org.apache.http.impl.conn.DefaultHttpResponseParser;Garbage in response: ÿþ{"id":0}HTTP/1.1 204 Could not find
Response in server logs by httpclient:
<204 No Content,{Cache-Control=[no-cache], Pragma=[no-cache], Content-Type=[application/json; charset=utf-16], Expires=[-1], Server=[some], X-AspNet-Version=[someversion], X-Powered-By=[ASP.NET], Date=[somedate]}>