MCPcopy Index your code
hub / github.com/OpenFeign/feign / decode

Method decode

moshi/src/main/java/feign/moshi/MoshiDecoder.java:45–63  ·  view source on GitHub ↗
(Response response, Type type)

Source from the content-addressed store, hash-verified

43 }
44
45 @Override
46 public Object decode(Response response, Type type) throws IOException {
47 JsonAdapter<Object> jsonAdapter = moshi.adapter(type);
48
49 if (response.status() == 404 || response.status() == 204) return Util.emptyValueOf(type);
50 if (response.body() == null) return null;
51
52 try (BufferedSource source = Okio.buffer(Okio.source(response.body().asInputStream()))) {
53 if (source.exhausted()) {
54 return null; // empty body
55 }
56 return jsonAdapter.fromJson(source);
57 } catch (JsonDataException e) {
58 if (e.getCause() != null && e.getCause() instanceof IOException) {
59 throw (IOException) e.getCause();
60 }
61 throw e;
62 }
63 }
64
65 @Override
66 public Object convert(Object object, Type type) throws IOException {

Callers 2

customDecoderMethod · 0.95
customObjectDecoderMethod · 0.95

Calls 5

emptyValueOfMethod · 0.95
fromJsonMethod · 0.80
bodyMethod · 0.65
asInputStreamMethod · 0.65
statusMethod · 0.45

Tested by 2

customDecoderMethod · 0.76
customObjectDecoderMethod · 0.76