Skip to content

Commit 0a71f48

Browse files
olegblfacebook-github-bot
authored andcommitted
Fix NetworkingModule losing Cookies when multiple CatalystInstances exist and one is destroyed
Differential Revision: D4451197 fbshipit-source-id: 905309f626a2295ecaa2451413e414eb827e10b0
1 parent f4bbf1b commit 0a71f48

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ public final class NetworkingModule extends ReactContextBaseJavaModule {
8888
client = clientBuilder.build();
8989
}
9090
mClient = client;
91-
OkHttpClientProvider.replaceOkHttpClient(client);
9291
mCookieHandler = new ForwardingCookieHandler(reactContext);
9392
mCookieJarContainer = (CookieJarContainer) mClient.cookieJar();
9493
mShuttingDown = false;
@@ -113,7 +112,7 @@ public final class NetworkingModule extends ReactContextBaseJavaModule {
113112
* @param context the ReactContext of the application
114113
*/
115114
public NetworkingModule(final ReactApplicationContext context) {
116-
this(context, null, OkHttpClientProvider.getOkHttpClient(), null);
115+
this(context, null, OkHttpClientProvider.createClient(), null);
117116
}
118117

119118
/**
@@ -124,7 +123,7 @@ public NetworkingModule(final ReactApplicationContext context) {
124123
public NetworkingModule(
125124
ReactApplicationContext context,
126125
List<NetworkInterceptorCreator> networkInterceptorCreators) {
127-
this(context, null, OkHttpClientProvider.getOkHttpClient(), networkInterceptorCreators);
126+
this(context, null, OkHttpClientProvider.createClient(), networkInterceptorCreators);
128127
}
129128

130129
/**
@@ -133,7 +132,7 @@ public NetworkingModule(
133132
* caller does not provide one explicitly
134133
*/
135134
public NetworkingModule(ReactApplicationContext context, String defaultUserAgent) {
136-
this(context, defaultUserAgent, OkHttpClientProvider.getOkHttpClient(), null);
135+
this(context, defaultUserAgent, OkHttpClientProvider.createClient(), null);
137136
}
138137

139138
@Override

ReactAndroid/src/main/java/com/facebook/react/modules/network/OkHttpClientProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static void replaceOkHttpClient(OkHttpClient client) {
4545
sClient = client;
4646
}
4747

48-
private static OkHttpClient createClient() {
48+
public static OkHttpClient createClient() {
4949
// No timeouts by default
5050
OkHttpClient.Builder client = new OkHttpClient.Builder()
5151
.connectTimeout(0, TimeUnit.MILLISECONDS)

0 commit comments

Comments
 (0)