fix nullsafe FIXMEs for PromiseImpl.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 PromiseImpl.java nullsafe

Reviewed By: alanleedev

Differential Revision: D72384070

fbshipit-source-id: 142a0e001af42ebb8cc1c8301b3ec7f586191d92
This commit is contained in:
Gijs Weterings authored and Facebook GitHub Bot committed 2025-04-09 09:07:30 -07:00
1 parent cad6f78f12
commit 4c8ea858a5
1 file changed
+9 -14
@@ -7,8 +7,8 @@
package com.facebook.react.bridge;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.proguard.annotations.DoNotStrip;
/*
@@ -18,6 +18,7 @@ import com.facebook.proguard.annotations.DoNotStrip;
* Methods annotated with {@link ReactMethod} that use a {@link Promise} as the last parameter
* will be marked as "promise" and will return a promise when invoked from JavaScript.
*/
@Nullsafe(Nullsafe.Mode.LOCAL)
@DoNotStrip
public class PromiseImpl implements Promise {
// Number of stack frames to parse and return to mReject.invoke
@@ -55,8 +56,7 @@ public class PromiseImpl implements Promise {
* @param value Object
*/
@Override
// NULLSAFE_FIXME[Inconsistent Subclass Parameter Annotation]
public void resolve(Object value) {
public void resolve(@Nullable Object value) {
if (mResolve != null) {
mResolve.invoke(value);
mResolve = null;
@@ -71,8 +71,7 @@ public class PromiseImpl implements Promise {
* @param message String
*/
@Override
// NULLSAFE_FIXME[Inconsistent Subclass Parameter Annotation]
public void reject(String code, String message) {
public void reject(String code, @Nullable String message) {
reject(code, message, /*Throwable*/ null, /*WritableMap*/ null);
}
@@ -83,8 +82,7 @@ public class PromiseImpl implements Promise {
* @param throwable Throwable
*/
@Override
// NULLSAFE_FIXME[Inconsistent Subclass Parameter Annotation]
public void reject(String code, Throwable throwable) {
public void reject(String code, @Nullable Throwable throwable) {
reject(code, /*Message*/ null, throwable, /*WritableMap*/ null);
}
@@ -96,8 +94,7 @@ public class PromiseImpl implements Promise {
* @param throwable Throwable
*/
@Override
// NULLSAFE_FIXME[Inconsistent Subclass Parameter Annotation]
public void reject(String code, String message, Throwable throwable) {
public void reject(String code, @Nullable String message, @Nullable Throwable throwable) {
reject(code, message, throwable, /*WritableMap*/ null);
}
@@ -135,7 +132,7 @@ public class PromiseImpl implements Promise {
* @param userInfo WritableMap
*/
@Override
public void reject(String code, @NonNull WritableMap userInfo) {
public void reject(String code, WritableMap userInfo) {
reject(code, /*Message*/ null, /*Throwable*/ null, userInfo);
}
@@ -147,8 +144,7 @@ public class PromiseImpl implements Promise {
* @param userInfo WritableMap
*/
@Override
// NULLSAFE_FIXME[Inconsistent Subclass Parameter Annotation]
public void reject(String code, Throwable throwable, WritableMap userInfo) {
public void reject(String code, @Nullable Throwable throwable, WritableMap userInfo) {
reject(code, /*Message*/ null, throwable, userInfo);
}
@@ -161,8 +157,7 @@ public class PromiseImpl implements Promise {
* @param userInfo WritableMap
*/
@Override
// NULLSAFE_FIXME[Inconsistent Subclass Parameter Annotation]
public void reject(String code, String message, @NonNull WritableMap userInfo) {
public void reject(String code, @Nullable String message, WritableMap userInfo) {
reject(code, message, /*Throwable*/ null, userInfo);
}