use of com.fasterxml.jackson.databind.RuntimeJsonMappingException in project feign by OpenFeign.
the class JacksonDecoder method decode.
@Override
public Object decode(Response response, Type type) throws IOException {
if (response.status() == 404)
return Util.emptyValueOf(type);
if (response.body() == null)
return null;
Reader reader = response.body().asReader();
if (!reader.markSupported()) {
reader = new BufferedReader(reader, 1);
}
try {
// Read the first byte to see if we have any data
reader.mark(1);
if (reader.read() == -1) {
// Eagerly returning null avoids "No content to map due to end-of-input"
return null;
}
reader.reset();
return mapper.readValue(reader, mapper.constructType(type));
} catch (RuntimeJsonMappingException e) {
if (e.getCause() != null && e.getCause() instanceof IOException) {
throw IOException.class.cast(e.getCause());
}
throw e;
}
}
Aggregations