Description
Affects: at least 3.2.1 to 3.3.4
The issue occurs when using RestTemplate to call another server as a client. There is a specific use case doesn't work as expected:
Steps to reproduce:
RestTemplate includes this line: restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory())); or an equivalent
Interceptor is created with a call getBody() on the result of ClientHttpRequestExecution.execute() inside of intercept() method override (for example, for logging purposes)
RestTemplate includes this interceptor
There is a call to restTemplate.exchange() with POST or PUT request, this request is expected to return an error (4xx or 5xx)
Expected result:
getBody() for the result of ClientHttpRequestExecution.execute() inside of the interceptor override is succesfully processed and the execution proceeds as usual, as BufferingClientHttpRequestFactory should provide the wrapped buffered response.
Actual result:
getBody() throws an IOException
Error demonstration:
https://github.com/Hotvianskyi/rest-remplate-bug