Enable error-prone checking in the net-utils-framework-common

Enable error-prone checking in the net-utils-framework-common to
catch NullablePrimitive errors during build time.

Also fix any NullablePrimitive errors that are found in the
library classes.

Bug: 256991804
Test: Enable error-prone checking and check if the build fails
      with any NullablePrimitive errors. If it does, fix the
      errors and build again.
Change-Id: I7e1508d166f258f5232ff39388ac984fbdc6169e
diff --git a/staticlibs/Android.bp b/staticlibs/Android.bp
index dad60f9..ff65228 100644
--- a/staticlibs/Android.bp
+++ b/staticlibs/Android.bp
@@ -265,6 +265,14 @@
         "//packages/apps/Settings",
     ],
     lint: { strict_updatability_linting: true },
+    errorprone: {
+        enabled: true,
+        // Error-prone checking only warns of problems when building. To make the build fail with
+        // these errors, list the specific error-prone problems below.
+        javacflags: [
+            "-Xep:NullablePrimitive:ERROR",
+        ],
+    },
 }
 
 java_library {
diff --git a/staticlibs/framework/com/android/net/module/util/CollectionUtils.java b/staticlibs/framework/com/android/net/module/util/CollectionUtils.java
index f08880c..39e7ce9 100644
--- a/staticlibs/framework/com/android/net/module/util/CollectionUtils.java
+++ b/staticlibs/framework/com/android/net/module/util/CollectionUtils.java
@@ -101,7 +101,6 @@
     /**
      * @return The index of the first element that matches the predicate, or -1 if none.
      */
-    @Nullable
     public static <T> int indexOf(@NonNull final Collection<T> elem,
             @NonNull final Predicate<? super T> predicate) {
         int idx = 0;