From af516266dbfbf72fb9954864931951bac702f4c8 Mon Sep 17 00:00:00 2001 From: Gijs Weterings Date: Wed, 9 Apr 2025 09:07:30 -0700 Subject: [PATCH] fix nullsafe FIXMEs for ViewManagerRegistry.java and mark nullsafe Summary: Gone trough all the FIXMEs added in the previous diff by the nullsafe tool, marked the class as nullsafe and ensured no remaining violations. Changelog: [Android][Fixed] Made ViewManagerRegistry.java nullsafe Reviewed By: alanleedev Differential Revision: D72384049 fbshipit-source-id: dbca38ee6379e2e64b37c1d265c001585344661d --- .../facebook/react/uimanager/ViewManagerRegistry.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerRegistry.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerRegistry.java index 36f8f5e0128..5885f67d077 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerRegistry.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerRegistry.java @@ -10,6 +10,7 @@ package com.facebook.react.uimanager; import android.content.ComponentCallbacks2; import android.content.res.Configuration; import androidx.annotation.Nullable; +import com.facebook.infer.annotation.Nullsafe; import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.common.MapBuilder; import java.util.ArrayList; @@ -20,6 +21,7 @@ import java.util.Map; * Class that stores the mapping between native view name used in JS and the corresponding instance * of {@link ViewManager}. */ +@Nullsafe(Nullsafe.Mode.LOCAL) public final class ViewManagerRegistry implements ComponentCallbacks2 { private final Map mViewManagers; @@ -86,9 +88,10 @@ public final class ViewManagerRegistry implements ComponentCallbacks2 { } private @Nullable ViewManager getViewManagerFromResolver(String className) { - @Nullable ViewManager viewManager; - // NULLSAFE_FIXME[Nullable Dereference] - viewManager = mViewManagerResolver.getViewManager(className); + @Nullable ViewManager viewManager = null; + if (mViewManagerResolver != null) { + viewManager = mViewManagerResolver.getViewManager(className); + } if (viewManager != null) { mViewManagers.put(className, viewManager); }