use of com.fasterxml.jackson.jr.ob.JSONObjectException in project feign by OpenFeign.
the class JacksonJrDecoder method decode.
@Override
public Object decode(Response response, Type type) throws IOException {
Transformer transformer = findTransformer(response, type);
if (response.body() == null) {
return null;
}
Reader reader = response.body().asReader(response.charset());
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 transformer.apply(mapper, reader);
} catch (JSONObjectException e) {
if (e.getCause() instanceof IOException) {
throw (IOException) e.getCause();
}
throw e;
}
}
Aggregations