spring-social / spring-social-google

Spring Social extension with connection support and an API binding for Google
https://spring-social-google.github.io/spring-social-google/
Apache License 2.0
214 stars 164 forks source link

I/O Error Attempted read from closed stream. #121

Closed mjeanroy closed 1 year ago

mjeanroy commented 3 years ago

Hi,

I tried to use the org.springframework.social.google.api.Google to fetch user information but in case Google respond a status code in error (say 503 in my case), I get an error "I/O Error Attempted read from closed stream.". This is due to an error handler that tries to log response body, as you can see here.

Then, spring RestTemplate tries to read the response body again to check if the response body is empty or not, then an I/O Error occurs since the response body can be consumed only once.

Note that I use Apache Http Component, not sure if the problem occurs with OkHTTP or other HTTP Client implementation.

A workaround is to use ERROR level for the given logger.