Simplify API of getReactApplicationContextIfActiveOrWarn

Summary:
Simplify the API of `getReactApplicationContextIfActiveOrWarn`. We don't need to pass so much information into this method to collect good SoftExceptions.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18134400

fbshipit-source-id: 0a250ab0252a44121f3339a31506a0a6c4c7cd35
This commit is contained in:
Joshua Gross
2019-10-25 16:16:00 -07:00
committed by Facebook Github Bot
parent a1a56fe4e5
commit 9446277fc1
14 changed files with 23 additions and 45 deletions
@@ -45,15 +45,15 @@ public abstract class ReactContextBaseJavaModule extends BaseJavaModule {
* thread-safe.
*/
@ThreadConfined(ANY)
protected @Nullable final ReactApplicationContext getReactApplicationContextIfActiveOrWarn(
String tag, String reason) {
protected @Nullable final ReactApplicationContext getReactApplicationContextIfActiveOrWarn() {
if (mReactApplicationContext.hasActiveCatalystInstance()) {
return mReactApplicationContext;
}
// We want to collect data about how often this happens, but SoftExceptions will cause a crash
// in debug mode, which isn't usually desirable.
String msg = "Catalyst Instance has already disappeared: " + reason;
String msg = "Catalyst Instance has already disappeared: requested by " + this.getName();
String tag = "ReactContextBaseJavaModule";
if (ReactBuildConfig.DEBUG) {
FLog.w(tag, msg);
} else {