File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
android/src/main/java/com/ReactNativeBlobUtil Expand file tree Collapse file tree 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 {
398398 clientBuilder .addInterceptor (new Interceptor () {
399399 @ Override
400400 public Response intercept (@ NonNull Chain chain ) throws IOException {
401+ Response originalResponse = null ;
401402 try {
402- Response originalResponse = chain .proceed (req );
403+ originalResponse = chain .proceed (req );
403404 ResponseBody extended ;
404405 switch (responseType ) {
405406 case KeepInMemory :
@@ -428,12 +429,21 @@ public Response intercept(@NonNull Chain chain) throws IOException {
428429 return originalResponse .newBuilder ().body (extended ).build ();
429430 } catch (SocketException e ) {
430431 timeout = true ;
432+ if (originalResponse != null ) {
433+ originalResponse .close ();
434+ }
431435 } catch (SocketTimeoutException e ) {
432436 timeout = true ;
437+ if (originalResponse != null ) {
438+ originalResponse .close ();
439+ }
433440 //ReactNativeBlobUtilUtils.emitWarningEvent("ReactNativeBlobUtil error when sending request : " + e.getLocalizedMessage());
434441 } catch (Exception ex ) {
435-
442+ if (originalResponse != null ) {
443+ originalResponse .close ();
444+ }
436445 }
446+
437447 return chain .proceed (chain .request ());
438448 }
439449 });
You can’t perform that action at this time.
0 commit comments