From 5803c72982efbd8e1bc64dbc7622cbd923e1729b Mon Sep 17 00:00:00 2001 From: David Vacca Date: Sun, 10 Jan 2021 19:44:28 -0800 Subject: [PATCH] Log SoftError when there is not EventDispatcher associated to UIManager Summary: This diff logs a SoftError when there is not EventDispatcher associated to UIManager The app will crash in Debug mode, this will not affect production users changelog: [internal] Reviewed By: JoshuaGross Differential Revision: D25859546 fbshipit-source-id: 8045bcd67f613ea6286f30fe6f3c66113c700b0b --- .../facebook/react/uimanager/UIManagerHelper.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerHelper.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerHelper.java index c276072a845..2ad3f029264 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerHelper.java @@ -111,7 +111,17 @@ public class UIManagerHelper { return ((EventDispatcherProvider) context).getEventDispatcher(); } UIManager uiManager = getUIManager(context, uiManagerType, false); - return uiManager == null ? null : (EventDispatcher) uiManager.getEventDispatcher(); + if (uiManager == null) { + return null; + } + EventDispatcher eventDispatcher = (EventDispatcher) uiManager.getEventDispatcher(); + if (eventDispatcher == null) { + ReactSoftException.logSoftException( + "UIManagerHelper", + new IllegalStateException( + "Cannot get EventDispatcher for UIManagerType " + uiManagerType)); + } + return eventDispatcher; } /**