mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-09-12 07:10:07 +02:00
- Catch IO exceptions during JSON deserialization
This commit is contained in:
parent
bef8711138
commit
5c9a10b878
@ -13,18 +13,17 @@ import java.io.InputStream;
|
|||||||
public class DebugMappingJacksonHttpMessageConverter extends MappingJacksonHttpMessageConverter {
|
public class DebugMappingJacksonHttpMessageConverter extends MappingJacksonHttpMessageConverter {
|
||||||
@Override
|
@Override
|
||||||
protected Object readInternal(Class<?> clazz, HttpInputMessage inputMessage) throws IOException, JsonHttpMessageNotReadableException {
|
protected Object readInternal(Class<?> clazz, HttpInputMessage inputMessage) throws IOException, JsonHttpMessageNotReadableException {
|
||||||
final byte[] bytes = IOUtils.toByteArray(inputMessage.getBody());
|
|
||||||
final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
|
|
||||||
final WrapHttpInputMessage wrap = new WrapHttpInputMessage(bais, inputMessage.getHeaders());
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
final byte[] bytes = IOUtils.toByteArray(inputMessage.getBody());
|
||||||
|
final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
|
||||||
|
final WrapHttpInputMessage wrap = new WrapHttpInputMessage(bais, inputMessage.getHeaders());
|
||||||
|
|
||||||
return super.readInternal(clazz, wrap);
|
return super.readInternal(clazz, wrap);
|
||||||
|
|
||||||
} catch (org.springframework.http.converter.HttpMessageNotReadableException e) {
|
} catch (org.springframework.http.converter.HttpMessageNotReadableException e) {
|
||||||
throw new JsonHttpMessageNotReadableException("Request Body:\n" + new String(bytes, "UTF-8"), e);
|
throw new JsonHttpMessageNotReadableException("Request Body could not be read", e);
|
||||||
}
|
} catch (IOException e) {
|
||||||
catch (IOException e) {
|
throw new JsonHttpMessageNotReadableException("Request Body could not be read", e);
|
||||||
throw new JsonHttpMessageNotReadableException("Request Body:\n" + new String(bytes, "UTF-8"), e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user