You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.
The RestTemplate doesn't throw only RestClientExceptions. In my case, when the mobile connection is lost, I can get a HttpMessageNotReadableException :
org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: recvfrom failed: ETIMEDOUT (Connection timed
out); nested exception is java.net.SocketException: recvfrom failed: ETIMEDOUT (Connection timed out)
E at org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.readInternal(MappingJacksonHttpMessageConverter.java:1
25)
E at org.springframework.http.converter.AbstractHttpMessageConverter.read(AbstractHttpMessageConverter.java:147)
E at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:76)
E at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:655)
E at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:641)
E at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:484)
E at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:447)
E at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:422)
The exception is not catched and so my app crashes miserably.
Maybe AA should allow RestErrorHandler to catch all kinds of RuntimeExceptions ?
The text was updated successfully, but these errors were encountered:
+1, this should definitely be the case, HttpMessageConversionException is thrown when there's a SocketException or org.apache.http.conn.HttpHostConnectException! RestErrorHandler and Spring's ResponseErrorHandler are only used once there is a valid connection so that the response can be identified; if something else happens (WiFi disconnect, server not reachable due to timeout) then you have to manually catch IOExceptions, which is definitely not a best practice solution.
The
RestTemplate
doesn't throw onlyRestClientExceptions
. In my case, when the mobile connection is lost, I can get aHttpMessageNotReadableException
:The exception is not catched and so my app crashes miserably.
Maybe AA should allow
RestErrorHandler
to catch all kinds ofRuntimeExceptions
?The text was updated successfully, but these errors were encountered: