File tree 1 file changed +12
-2
lines changed
android/src/main/java/com/ReactNativeBlobUtil
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -398,8 +398,9 @@ public Response intercept(Chain chain) throws IOException {
398
398
clientBuilder .addInterceptor (new Interceptor () {
399
399
@ Override
400
400
public Response intercept (@ NonNull Chain chain ) throws IOException {
401
+ Response originalResponse = null ;
401
402
try {
402
- Response originalResponse = chain .proceed (req );
403
+ originalResponse = chain .proceed (req );
403
404
ResponseBody extended ;
404
405
switch (responseType ) {
405
406
case KeepInMemory :
@@ -428,12 +429,21 @@ public Response intercept(@NonNull Chain chain) throws IOException {
428
429
return originalResponse .newBuilder ().body (extended ).build ();
429
430
} catch (SocketException e ) {
430
431
timeout = true ;
432
+ if (originalResponse != null ) {
433
+ originalResponse .close ();
434
+ }
431
435
} catch (SocketTimeoutException e ) {
432
436
timeout = true ;
437
+ if (originalResponse != null ) {
438
+ originalResponse .close ();
439
+ }
433
440
//ReactNativeBlobUtilUtils.emitWarningEvent("ReactNativeBlobUtil error when sending request : " + e.getLocalizedMessage());
434
441
} catch (Exception ex ) {
435
-
442
+ if (originalResponse != null ) {
443
+ originalResponse .close ();
444
+ }
436
445
}
446
+
437
447
return chain .proceed (chain .request ());
438
448
}
439
449
});
You can’t perform that action at this time.
0 commit comments