From 8d861106bcdf8724c449948e357eae008365965b Mon Sep 17 00:00:00 2001 From: Jocelyn Luizzi Date: Wed, 24 Jul 2024 12:37:31 -0700 Subject: [PATCH] NetworkFlipperPlugin#'s param 'formatters' Receives Null Value Summary: mark formatters nullsafe as stated by the error code: ``` 07-23 16:21:27.445 4845 4845 E AndroidRuntime: Caused by: java.lang.IllegalArgumentException: NetworkFlipperPlugin#'s param 'formatters' received null value, but is not marked as Nullable. 07-23 16:21:27.445 4845 4845 E AndroidRuntime: at com.facebook.flipper.plugins.network.NetworkFlipperPlugin.(NetworkFlipperPlugin.java:1) 07-23 16:21:27.445 4845 4845 E AndroidRuntime: at com.facebook.flipper.plugins.network.NetworkFlipperPlugin.(NetworkFlipperPlugin.java:27) 07-23 16:21:27.445 4845 4845 E AndroidRuntime: at com.instagram.appinitializer.devtools.FlipperInitializer.init(FlipperInitializer.java:96) 07-23 16:21:27.445 4845 4845 E AndroidRuntime: at com.instagram.appinitializer.devtools.DevToolInitializer.init(DevToolInitializer.kt:27) ``` Also add nullable to field set to null + method returning null explicitly ## Context We are in the process of making the entire codebase Nullsafe. This diff relies on a runtime codemod to track when null is passed into a parameter that is not marked as Nullable in java. Based on runtime data, we can be 100% certain that this parameter needs to be Nullable Reviewed By: nicholeic Differential Revision: D60174408 fbshipit-source-id: 0e41badfa743445bb295af25da30faaffcdc5477 --- .../flipper/plugins/network/NetworkFlipperPlugin.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/android/plugins/network/src/main/java/com/facebook/flipper/plugins/network/NetworkFlipperPlugin.java b/android/plugins/network/src/main/java/com/facebook/flipper/plugins/network/NetworkFlipperPlugin.java index f3499d46d3b..d1b3f8aa36c 100644 --- a/android/plugins/network/src/main/java/com/facebook/flipper/plugins/network/NetworkFlipperPlugin.java +++ b/android/plugins/network/src/main/java/com/facebook/flipper/plugins/network/NetworkFlipperPlugin.java @@ -20,14 +20,14 @@ public class NetworkFlipperPlugin extends BufferingFlipperPlugin implements Netw public static final String ID = "Network"; private static final int MAX_BODY_SIZE_IN_BYTES = 1024 * 1024; - private List mFormatters; - private final List mRequestFormatters; + private @Nullable List mFormatters; + private @Nullable final List mRequestFormatters; public NetworkFlipperPlugin() { this(null); } - public NetworkFlipperPlugin(List formatters) { + public NetworkFlipperPlugin(@Nullable List formatters) { this.mFormatters = formatters; this.mRequestFormatters = null; } @@ -171,7 +171,7 @@ protected void runOrThrow() throws Exception { .run(); } - public static String toBase64(@Nullable byte[] bytes) { + public static @Nullable String toBase64(@Nullable byte[] bytes) { if (bytes == null) { return null; }