Skip to content

Commit

Permalink
NetworkFlipperPlugin#<init>'s param 'formatters' Receives Null Value
Browse files Browse the repository at this point in the history
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#<init>'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.<init>(NetworkFlipperPlugin.java:1)
07-23 16:21:27.445  4845  4845 E AndroidRuntime: 	at com.facebook.flipper.plugins.network.NetworkFlipperPlugin.<init>(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
  • Loading branch information
jocelynluizzi13 authored and facebook-github-bot committed Jul 24, 2024
1 parent 5dbc2dd commit 8d86110
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<NetworkResponseFormatter> mFormatters;
private final List<NetworkRequestFormatter> mRequestFormatters;
private @Nullable List<NetworkResponseFormatter> mFormatters;
private @Nullable final List<NetworkRequestFormatter> mRequestFormatters;

public NetworkFlipperPlugin() {
this(null);
}

public NetworkFlipperPlugin(List<NetworkResponseFormatter> formatters) {
public NetworkFlipperPlugin(@Nullable List<NetworkResponseFormatter> formatters) {
this.mFormatters = formatters;
this.mRequestFormatters = null;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 8d86110

Please sign in to comment.