diff --git a/moshi/src/main/java/feign/moshi/MoshiDecoder.java b/moshi/src/main/java/feign/moshi/MoshiDecoder.java index 02b76f689..23c7fe855 100644 --- a/moshi/src/main/java/feign/moshi/MoshiDecoder.java +++ b/moshi/src/main/java/feign/moshi/MoshiDecoder.java @@ -21,7 +21,6 @@ import feign.codec.Decoder; import okio.BufferedSource; import okio.Okio; - import java.io.IOException; import java.lang.reflect.Type; @@ -50,6 +49,9 @@ public Object decode(Response response, Type type) throws IOException { return null; try (BufferedSource source = Okio.buffer(Okio.source(response.body().asInputStream()))) { + if (source.exhausted()) { + return null; // empty body + } return jsonAdapter.fromJson(source); } catch (JsonDataException e) { if (e.getCause() != null && e.getCause() instanceof IOException) {