From 4378ecb8e174ebcc63e5dc8204f55a9015367a45 Mon Sep 17 00:00:00 2001 From: Konstantin Raev Date: Mon, 23 May 2016 04:40:20 -0700 Subject: [PATCH] Fixes NPE when NetworkingModule runs onCatalystInstanceDestroy Reviewed By: andreicoman11 Differential Revision: D3328278 fbshipit-source-id: 7cf43a4564b2b799b13307f8604eb48e5c512379 --- .../com/facebook/react/common/network/OkHttpCallUtil.java | 4 ++++ .../com/facebook/react/modules/network/NetworkingModule.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/common/network/OkHttpCallUtil.java b/ReactAndroid/src/main/java/com/facebook/react/common/network/OkHttpCallUtil.java index 4da3a5e9b..7fa7d967a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/common/network/OkHttpCallUtil.java +++ b/ReactAndroid/src/main/java/com/facebook/react/common/network/OkHttpCallUtil.java @@ -32,4 +32,8 @@ public class OkHttpCallUtil { } } } + + public static void cancelAll(OkHttpClient client) { + client.dispatcher().cancelAll(); + } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.java index 93ab7f7b0..68e6e93b0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.java @@ -138,7 +138,7 @@ public final class NetworkingModule extends ReactContextBaseJavaModule { @Override public void onCatalystInstanceDestroy() { mShuttingDown = true; - OkHttpCallUtil.cancelTag(mClient, null); + OkHttpCallUtil.cancelAll(mClient); mCookieHandler.destroy(); mCookieJarContainer.removeCookieJar();