From af4f0d0cff365e3849d306ed2400d4bf8f368fc4 Mon Sep 17 00:00:00 2001 From: Gijs Weterings Date: Thu, 3 Apr 2025 08:01:59 -0700 Subject: [PATCH] Apply Nullsafe FIXMEs for xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/internal/bolts/Task.java (#50361) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/50361 Added nullsafe FIXMEs for easier reviewing of next diff, where we fix them Changelog: [Internal] Reviewed By: cortinico Differential Revision: D71979592 fbshipit-source-id: 07f3b74362b85803eec90c0c974a88d061d8e816 --- .../com/facebook/react/runtime/internal/bolts/Task.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/internal/bolts/Task.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/internal/bolts/Task.java index 24f1406990d..5446df15cfc 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/internal/bolts/Task.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/internal/bolts/Task.java @@ -75,9 +75,12 @@ public class Task implements TaskInterface { private final Object lock = new Object(); private boolean complete; private boolean cancelled; + // NULLSAFE_FIXME[Field Not Initialized] private TResult result; + // NULLSAFE_FIXME[Field Not Initialized] private Exception error; private boolean errorHasBeenObserved; + // NULLSAFE_FIXME[Field Not Initialized] private UnobservedErrorNotifier unobservedErrorNotifier; private List> continuations = new ArrayList<>(); @@ -91,6 +94,7 @@ public class Task implements TaskInterface { if (cancelled) { trySetCancelled(); } else { + // NULLSAFE_FIXME[Parameter Not Nullable] trySetResult(null); } } @@ -151,6 +155,7 @@ public class Task implements TaskInterface { errorHasBeenObserved = true; if (unobservedErrorNotifier != null) { unobservedErrorNotifier.setObserved(); + // NULLSAFE_FIXME[Field Not Nullable] unobservedErrorNotifier = null; } } @@ -175,6 +180,7 @@ public class Task implements TaskInterface { * false} otherwise. */ @Override + // NULLSAFE_FIXME[Inconsistent Subclass Parameter Annotation] public boolean waitForCompletion(long duration, TimeUnit timeUnit) throws InterruptedException { synchronized (lock) { if (!isCompleted()) { @@ -489,6 +495,7 @@ public class Task implements TaskInterface { throw new RuntimeException(e); } } + // NULLSAFE_FIXME[Field Not Nullable] continuations = null; } } @@ -538,6 +545,7 @@ public class Task implements TaskInterface { } } + // NULLSAFE_FIXME[Parameter Not Nullable] private static Task TASK_NULL = new Task<>(null); private static Task TASK_TRUE = new Task<>((Boolean) true); private static Task TASK_FALSE = new Task<>((Boolean) false);