Skip to content

Commit

Permalink
silence exception
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianha committed Jun 14, 2023
1 parent b8c6075 commit 135f5c8
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ private static InputStream getDownloadFileInputStream(Context context, Uri uri)
return RequestBody.create(mediaType, gzipByteArrayOutputStream.toByteArray());
}

private static void closeQuietly(Source source) {
try {
source.close();
} catch (IOException e) {
// noop.
}
}

/** Creates a RequestBody from a mediaType and inputStream given. */
public static RequestBody create(final MediaType mediaType, final InputStream inputStream) {
return new RequestBody() {
Expand All @@ -151,7 +159,7 @@ public void writeTo(BufferedSink sink) throws IOException {
source = Okio.source(inputStream);
sink.writeAll(source);
} finally {
source.close();
closeQuietly(source);
}
}
};
Expand Down

0 comments on commit 135f5c8

Please sign in to comment.