From fbeb51ef5133303a5cb71569507d44403ded3447 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Tue, 12 Apr 2022 12:18:14 -0700 Subject: [PATCH] Fix NullPointerException when disaptching events Summary: This diff fixes a NullPointerException when disaptching events while the SurfaceMountingManager is being destroyed changelog: [android] android Reviewed By: cortinico Differential Revision: D35559550 fbshipit-source-id: c07f74493384fb1b306338ec1bc8b96f1b6f1f41 --- .../react/fabric/mounting/SurfaceMountingManager.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java index b9c8a6c2358ddc..f1d28f26bf55fd 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java @@ -1026,13 +1026,14 @@ public View getView(int reactTag) { } private @Nullable ViewState getNullableViewState(int tag) { - if (mTagToViewState == null) { + ConcurrentHashMap viewStates = mTagToViewState; + if (viewStates == null) { return null; } if (ReactFeatureFlags.enableDelayedViewStateDeletion) { mScheduledForDeletionViewStateTags.remove(tag); } - return mTagToViewState.get(tag); + return viewStates.get(tag); } @SuppressWarnings("unchecked") // prevents unchecked conversion warn of the type