Wrap IOException as HttpMessageNotReadableException for RestTemplate usage

In the 4.3.x line, conversion exceptions do not get wrapped as RestClientException yet, so the expectation remains to receive a HttpMessageNotReadableException for conversion-level IOExceptions.

Issue: SPR-13592
This commit is contained in:
Juergen Hoeller
2017-05-08 08:42:06 +02:00
parent 9572859a35
commit 81143a80c4
2 changed files with 9 additions and 16 deletions

View File

@@ -219,7 +219,7 @@ public abstract class AbstractJackson2HttpMessageConverter extends AbstractGener
return readJavaType(javaType, inputMessage);
}
private Object readJavaType(JavaType javaType, HttpInputMessage inputMessage) throws IOException {
private Object readJavaType(JavaType javaType, HttpInputMessage inputMessage) {
try {
if (inputMessage instanceof MappingJacksonInputMessage) {
Class<?> deserializationView = ((MappingJacksonInputMessage) inputMessage).getDeserializationView();
@@ -233,6 +233,9 @@ public abstract class AbstractJackson2HttpMessageConverter extends AbstractGener
catch (JsonProcessingException ex) {
throw new HttpMessageNotReadableException("JSON parse error: " + ex.getOriginalMessage(), ex);
}
catch (IOException ex) {
throw new HttpMessageNotReadableException("I/O error while reading input message", ex);
}
}
@Override