提交 62b2290f 编写于 作者: J Jake Wharton

Merge pull request #1266 from SimonScholz/master

Make Retrofit ready for usage in OSGi
......@@ -32,7 +32,12 @@ final class GsonResponseBodyConverter<T> implements Converter<ResponseBody, T> {
try {
return adapter.fromJson(reader);
} finally {
Utils.closeQuietly(reader);
if (reader != null) {
try {
reader.close();
} catch (IOException ignored) {
}
}
}
}
}
......@@ -32,7 +32,12 @@ final class JacksonResponseBodyConverter<T> implements Converter<ResponseBody, T
try {
return adapter.readValue(reader);
} finally {
Utils.closeQuietly(reader);
if (reader != null) {
try {
reader.close();
} catch (IOException ignored) {
}
}
}
}
}
......@@ -32,7 +32,12 @@ final class MoshiResponseBodyConverter<T> implements Converter<ResponseBody, T>
try {
return adapter.fromJson(source);
} finally {
Utils.closeQuietly(source);
if (source != null) {
try {
source.close();
} catch (IOException ignored) {
}
}
}
}
}
......@@ -37,7 +37,12 @@ final class ProtoResponseBodyConverter<T extends MessageLite>
} catch (InvalidProtocolBufferException e) {
throw new RuntimeException(e); // Despite extending IOException, this is data mismatch.
} finally {
Utils.closeQuietly(is);
if (is != null) {
try {
is.close();
} catch (IOException ignored) {
}
}
}
}
}
......@@ -30,11 +30,17 @@ final class WireResponseBodyConverter<T extends Message<T, ?>>
}
@Override public T convert(ResponseBody value) throws IOException {
BufferedSource source = null;
try {
BufferedSource source = value.source();
source = value.source();
return adapter.decode(source);
} finally {
Utils.closeQuietly(value);
if (source != null) {
try {
source.close();
} catch (IOException ignored) {
}
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册