OSDN Git Service

Fix @NonNull -> Nullable for Intent.replaceExtras().
authorTobias Thierer <tobiast@google.com>
Sun, 23 Dec 2018 14:25:58 +0000 (14:25 +0000)
committerTobias Thierer <tobiast@google.com>
Sun, 23 Dec 2018 14:26:08 +0000 (14:26 +0000)
extras == null is documented to result in all extras being
erased, and the implementation handles it correctly. The
@NonNull annotation on Bundle extras is therefore wrong.
This CL replaces it with the correct annotation, @Nullable.

The incorrect annotation was introduced in April 2017
(commit 30e06bb668f2e4b024c4ebc2a131de91c96de5eb). I've
looked through the other changes to Intent.java in that
commit but have found no further nullability annotation
errors.

Bug: 121438778
Test: Treehugger
Test: Looked through the other nullability annotations on
      Intent.java introduced by the same commit
      30e06bb668f2e4b024c4ebc2a131de91c96de5eb (Apr 2017)
      but found no further errors.

Change-Id: Iebbe17abc5c97146533e82114fbaf1d7036fd03a

core/java/android/content/Intent.java

index 2b60770..bc62b9e 100644 (file)
@@ -9062,7 +9062,7 @@ public class Intent implements Parcelable, Cloneable {
      * @param extras The new set of extras in the Intent, or null to erase
      * all extras.
      */
-    public @NonNull Intent replaceExtras(@NonNull Bundle extras) {
+    public @NonNull Intent replaceExtras(@Nullable Bundle extras) {
         mExtras = extras != null ? new Bundle(extras) : null;
         return this;
     }