Skip to content

Commit

Permalink
silence exception
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianha authored and cortinico committed Jun 14, 2023
1 parent 3936453 commit 7730b9d
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 7730b9d

Please sign in to comment.