Refactor calls to UIManagerHelper.getUIManager

Summary:
This diff refactors the usages of UIManagerHelper.getUIManager() to make sure we always consider null objects.
Some of the callsites were throwing a NullPointerExcetpion, now they throw a more explicit exception.

changelog: [internal]

Reviewed By: makovkastar

Differential Revision: D19383064

fbshipit-source-id: 1806a37528e80cab1c8fdff5eb631aaf47bde819
This commit is contained in:
David Vacca
2020-01-22 17:46:59 -08:00
committed by Facebook Github Bot
parent edcbfb9821
commit 39089b4c45
3 changed files with 33 additions and 21 deletions
@@ -1104,12 +1104,16 @@ public class ReactInstanceManager {
Log.d(ReactConstants.TAG, "ReactInstanceManager.attachRootViewToInstance()");
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "attachRootViewToInstance");
// UIManager is technically Nullable here, but if we can't get a UIManager
// at this point, something has probably gone horribly wrong so it's probably best
// to throw a NullPointerException.
@Nullable
UIManager uiManager =
UIManagerHelper.getUIManager(mCurrentReactContext, reactRoot.getUIManagerType());
// If we can't get a UIManager something has probably gone horribly wrong
if (uiManager == null) {
throw new IllegalStateException(
"Unable to attache a rootView to ReactInstance when UIManager is not properly initialized.");
}
@Nullable Bundle initialProperties = reactRoot.getAppProperties();
final int rootTag =