Don't crash on second resolve or reject in PromiseImpl. (#20303)

Summary:
Promise semantics per JS should allow calling resolve or reject repeatedly without crashing. Only the first one should do anything, but others should be allowed. This change fixes the Java bridge for Android. A separate change is needed for iOS.

Issue #20262
Pull Request resolved: https://github.com/facebook/react-native/pull/20303

Differential Revision: D13396975

Pulled By: cpojer

fbshipit-source-id: 81f14f73654fa7c44e043f574a39fda481ace44b
This commit is contained in:
Elliott Sprehn 2018-12-10 05:54:14 -08:00 committed by Facebook Github Bot
parent 3592122af3
commit 167d7861cb
1 changed files with 4 additions and 0 deletions

View File

@ -28,6 +28,8 @@ public class PromiseImpl implements Promise {
public void resolve(Object value) {
if (mResolve != null) {
mResolve.invoke(value);
mResolve = null;
mReject = null;
}
}
@ -67,5 +69,7 @@ public class PromiseImpl implements Promise {
// TODO(8850038): add the stack trace info in, need to figure out way to serialize that
mReject.invoke(errorInfo);
}
mResolve = null;
mReject = null;
}
}