jenkins-bot has submitted this change and it was merged. Change subject: Do not allow getStringSet() to be modified ......................................................................
Do not allow getStringSet() to be modified Unconditionally prohibit modifications to the result of SharedPreferences.getStringSet(). The Javadocs warn: Note that you must not modify the set instance returned by this call. The consistency of the stored data is not guaranteed if you do, nor is your ability to modify the instance at all. This seems like it would have the potential to cause data loss sporadically. Change-Id: I01221423aab52f29a5a9066a7cbdbbc10e4f0c90 --- M app/src/main/java/org/wikipedia/settings/PrefsIoUtil.java 1 file changed, 3 insertions(+), 1 deletion(-) Approvals: Mholloway: Looks good to me, approved jenkins-bot: Verified diff --git a/app/src/main/java/org/wikipedia/settings/PrefsIoUtil.java b/app/src/main/java/org/wikipedia/settings/PrefsIoUtil.java index 047bd58..9883555 100644 --- a/app/src/main/java/org/wikipedia/settings/PrefsIoUtil.java +++ b/app/src/main/java/org/wikipedia/settings/PrefsIoUtil.java @@ -10,6 +10,7 @@ import org.wikipedia.WikipediaApp; +import java.util.Collections; import java.util.Set; /** Shared preferences input / output utility providing set* functionality that writes to SP on the @@ -69,7 +70,8 @@ @Nullable public static Set<String> getStringSet(String key, @Nullable Set<String> defaultValue) { - return getPreferences().getStringSet(key, defaultValue); + Set<String> set = getPreferences().getStringSet(key, defaultValue); + return set == null ? null : Collections.unmodifiableSet(set); } public static void setStringSet(String key, @Nullable Set<String> value) { -- To view, visit https://gerrit.wikimedia.org/r/316385 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I01221423aab52f29a5a9066a7cbdbbc10e4f0c90 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