Skip to content

Commit

Permalink
Fix NetworkingModule losing Cookies when multiple CatalystInstances e…
Browse files Browse the repository at this point in the history
…xist and one is destroyed

Differential Revision: D4451197

fbshipit-source-id: 905309f626a2295ecaa2451413e414eb827e10b0
  • Loading branch information
olegbl authored and facebook-github-bot committed Feb 3, 2017
1 parent f4bbf1b commit 0a71f48
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

/**
Expand All @@ -124,7 +123,7 @@ public NetworkingModule(final ReactApplicationContext context) {
public NetworkingModule(
ReactApplicationContext context,
List<NetworkInterceptorCreator> networkInterceptorCreators) {
this(context, null, OkHttpClientProvider.getOkHttpClient(), networkInterceptorCreators);
this(context, null, OkHttpClientProvider.createClient(), networkInterceptorCreators);
}

/**
Expand All @@ -133,7 +132,7 @@ public NetworkingModule(
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static void replaceOkHttpClient(OkHttpClient client) {
sClient = client;
}

private static OkHttpClient createClient() {
public static OkHttpClient createClient() {
// No timeouts by default
OkHttpClient.Builder client = new OkHttpClient.Builder()
.connectTimeout(0, TimeUnit.MILLISECONDS)
Expand Down

0 comments on commit 0a71f48

Please sign in to comment.