-
Notifications
You must be signed in to change notification settings - Fork 38.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RestTemplate with interceptor calling response getBody() throws IOException even if BufferingClientHttpRequestFactory is set #33662
Comments
Have you tried following Andy's advice here? Is it working out for you? |
I don't think ignoring IOException is a solution that I am willing to apply. It ether should be another more specific exception or no exception at all at that stage. |
This might be the same as #33020. |
Thanks for the comment @nrayburn-tech , I think this is right. @Hotvianskyi I have upgraded your sample to Spring Boot 3.4.0-M3 and updated your test case with the following:
We're not getting While the behavior is not great, this is an important behavior change and I believe this is why this was not backported to a maintenance version in 6.1.x. I'm closing this issue as a duplicate then. Thanks for this report! |
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
The text was updated successfully, but these errors were encountered: