[MediaWiki-commits] [Gerrit] apps...wikipedia[master]: Make User Set input immutable
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 edit = Collections.emptySet(); +@SuppressWarnings("MismatchedReadAndWriteOfArray") @NonNull private Set edit = Collections.emptySet(); // TODO should send them all, but callers need to be updated, too, (future patch) @Nullable @@ -20,4 +20,4 @@ public Set 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: NiedzielskiGerrit-Reviewer: BearND Gerrit-Reviewer: Brion VIBBER Gerrit-Reviewer: Dbrant Gerrit-Reviewer: Mholloway Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] apps...wikipedia[master]: Make User Set input immutable
Niedzielski has uploaded a new change for review. https://gerrit.wikimedia.org/r/316389 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(-) git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia refs/changes/89/316389/1 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 edit = Collections.emptySet(); +@SuppressWarnings("MismatchedReadAndWriteOfArray") @NonNull private Set edit = Collections.emptySet(); // TODO should send them all, but callers need to be updated, too, (future patch) @Nullable @@ -20,4 +20,4 @@ public Set 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: newchange Gerrit-Change-Id: I413059a8c38cacba4a2fd0cad0663b8e2542a84e Gerrit-PatchSet: 1 Gerrit-Project: apps/android/wikipedia Gerrit-Branch: master Gerrit-Owner: Niedzielski___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits