Fail-Fast on Redundant Java Callback Invocations
Reviewed By: dcaspi Differential Revision: D4354731 fbshipit-source-id: d23351f23c8c5962da60af77340166fcb1314d78
This commit is contained in:
parent
8305743725
commit
e64618374b
|
@ -17,15 +17,23 @@ public final class CallbackImpl implements Callback {
|
|||
private final CatalystInstance mCatalystInstance;
|
||||
private final ExecutorToken mExecutorToken;
|
||||
private final int mCallbackId;
|
||||
private boolean mInvoked;
|
||||
|
||||
public CallbackImpl(CatalystInstance bridge, ExecutorToken executorToken, int callbackId) {
|
||||
mCatalystInstance = bridge;
|
||||
mExecutorToken = executorToken;
|
||||
mCallbackId = callbackId;
|
||||
mInvoked = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(Object... args) {
|
||||
if (mInvoked) {
|
||||
throw new RuntimeException("Illegal callback invocation from native "+
|
||||
"module. This callback type only permits a single invocation from "+
|
||||
"native code.");
|
||||
}
|
||||
mCatalystInstance.invokeCallback(mExecutorToken, mCallbackId, Arguments.fromJavaArgs(args));
|
||||
mInvoked = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue