jenkins-bot has submitted this change and it was merged.

Change subject: Make User Set input immutable
......................................................................


Make User Set input immutable

Make a copy of the passed in group Set to ensure the collection is
immutable. Also, add a missed @NonNull to Protection.edit.

Change-Id: I413059a8c38cacba4a2fd0cad0663b8e2542a84e
---
M app/src/main/java/org/wikipedia/login/User.java
M app/src/main/java/org/wikipedia/server/Protection.java
2 files changed, 4 insertions(+), 3 deletions(-)

Approvals:
  Mholloway: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/app/src/main/java/org/wikipedia/login/User.java 
b/app/src/main/java/org/wikipedia/login/User.java
index 8316fd0..b379c60 100644
--- a/app/src/main/java/org/wikipedia/login/User.java
+++ b/app/src/main/java/org/wikipedia/login/User.java
@@ -5,6 +5,7 @@
 import android.support.annotation.VisibleForTesting;
 
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.Set;
 
 public class User {
@@ -64,7 +65,7 @@
         this.password = password;
         this.userID = userID;
         if (groups != null) {
-            this.groups = Collections.unmodifiableSet(groups);
+            this.groups = Collections.unmodifiableSet(new HashSet<>(groups));
         } else {
             this.groups = Collections.emptySet();
         }
diff --git a/app/src/main/java/org/wikipedia/server/Protection.java 
b/app/src/main/java/org/wikipedia/server/Protection.java
index 3612a08..a77daba 100644
--- a/app/src/main/java/org/wikipedia/server/Protection.java
+++ b/app/src/main/java/org/wikipedia/server/Protection.java
@@ -8,7 +8,7 @@
 
 /** Protection settings for a page */
 public class Protection {
-    @SuppressWarnings("MismatchedReadAndWriteOfArray") private Set<String> 
edit = Collections.emptySet();
+    @SuppressWarnings("MismatchedReadAndWriteOfArray") @NonNull private 
Set<String> edit = Collections.emptySet();
 
     // TODO should send them all, but callers need to be updated, too, (future 
patch)
     @Nullable
@@ -20,4 +20,4 @@
     public Set<String> getEditRoles() {
         return Collections.unmodifiableSet(edit);
     }
-}
\ No newline at end of file
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/316389
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I413059a8c38cacba4a2fd0cad0663b8e2542a84e
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Niedzielski <sniedziel...@wikimedia.org>
Gerrit-Reviewer: BearND <bsitzm...@wikimedia.org>
Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org>
Gerrit-Reviewer: Dbrant <dbr...@wikimedia.org>
Gerrit-Reviewer: Mholloway <mhollo...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to