Fix NPE in cancelling network calls
Summary: Issue reported here https://github.com/facebook/react-native/issues/7755#issuecomment-222950463 Converting int to Integer explicitly and not cancelling the call more than once should fix it. Reviewed By: bestander Differential Revision: D3371238 fbshipit-source-id: cb00663b4ca19a788bd27b971b6447cc0788a818
This commit is contained in:
parent
8fe58849a5
commit
5de1151bdd
|
@ -24,11 +24,13 @@ public class OkHttpCallUtil {
|
|||
for (Call call : client.dispatcher().queuedCalls()) {
|
||||
if (tag.equals(call.request().tag())) {
|
||||
call.cancel();
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (Call call : client.dispatcher().runningCalls()) {
|
||||
if (tag.equals(call.request().tag())) {
|
||||
call.cancel();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -384,7 +384,7 @@ public final class NetworkingModule extends ReactContextBaseJavaModule {
|
|||
new GuardedAsyncTask<Void, Void>(getReactApplicationContext()) {
|
||||
@Override
|
||||
protected void doInBackgroundGuarded(Void... params) {
|
||||
OkHttpCallUtil.cancelTag(mClient, requestId);
|
||||
OkHttpCallUtil.cancelTag(mClient, Integer.valueOf(requestId));
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue