Skip to content

Commit 7730b9d

Browse files
adrianhacortinico
authored andcommitted
silence exception
1 parent 3936453 commit 7730b9d

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

  • packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/network

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/network/RequestBodyUtil.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ private static InputStream getDownloadFileInputStream(Context context, Uri uri)
127127
return RequestBody.create(mediaType, gzipByteArrayOutputStream.toByteArray());
128128
}
129129

130+
private static void closeQuietly(Source source) {
131+
try {
132+
source.close();
133+
} catch (IOException e) {
134+
// noop.
135+
}
136+
}
137+
130138
/** Creates a RequestBody from a mediaType and inputStream given. */
131139
public static RequestBody create(final MediaType mediaType, final InputStream inputStream) {
132140
return new RequestBody() {
@@ -151,7 +159,7 @@ public void writeTo(BufferedSink sink) throws IOException {
151159
source = Okio.source(inputStream);
152160
sink.writeAll(source);
153161
} finally {
154-
source.close();
162+
closeQuietly(source);
155163
}
156164
}
157165
};

0 commit comments

Comments
 (0)