Fix NetworkingModule losing Cookies when multiple CatalystInstances exist and one is destroyed

Differential Revision: D4451197

fbshipit-source-id: 905309f626a2295ecaa2451413e414eb827e10b0
This commit is contained in:
Oleg Lokhvitsky 2017-02-03 12:49:57 -08:00 committed by Facebook Github Bot
parent f4bbf1bc62
commit 0a71f48b13
2 changed files with 4 additions and 5 deletions

View File

@ -88,7 +88,6 @@ public final class NetworkingModule extends ReactContextBaseJavaModule {
client = clientBuilder.build();
}
mClient = client;
OkHttpClientProvider.replaceOkHttpClient(client);
mCookieHandler = new ForwardingCookieHandler(reactContext);
mCookieJarContainer = (CookieJarContainer) mClient.cookieJar();
mShuttingDown = false;
@ -113,7 +112,7 @@ public final class NetworkingModule extends ReactContextBaseJavaModule {
* @param context the ReactContext of the application
*/
public NetworkingModule(final ReactApplicationContext context) {
this(context, null, OkHttpClientProvider.getOkHttpClient(), null);
this(context, null, OkHttpClientProvider.createClient(), null);
}
/**
@ -124,7 +123,7 @@ public final class NetworkingModule extends ReactContextBaseJavaModule {
public NetworkingModule(
ReactApplicationContext context,
List<NetworkInterceptorCreator> networkInterceptorCreators) {
this(context, null, OkHttpClientProvider.getOkHttpClient(), networkInterceptorCreators);
this(context, null, OkHttpClientProvider.createClient(), networkInterceptorCreators);
}
/**
@ -133,7 +132,7 @@ public final class NetworkingModule extends ReactContextBaseJavaModule {
* caller does not provide one explicitly
*/
public NetworkingModule(ReactApplicationContext context, String defaultUserAgent) {
this(context, defaultUserAgent, OkHttpClientProvider.getOkHttpClient(), null);
this(context, defaultUserAgent, OkHttpClientProvider.createClient(), null);
}
@Override

View File

@ -45,7 +45,7 @@ public class OkHttpClientProvider {
sClient = client;
}
private static OkHttpClient createClient() {
public static OkHttpClient createClient() {
// No timeouts by default
OkHttpClient.Builder client = new OkHttpClient.Builder()
.connectTimeout(0, TimeUnit.MILLISECONDS)