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

Change-Id: I01221423aab52f29a5a9066a7cbdbbc10e4f0c90
M app/src/main/java/org/wikipedia/settings/
1 file changed, 3 insertions(+), 1 deletion(-)

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

diff --git a/app/src/main/java/org/wikipedia/settings/ 
index 047bd58..9883555 100644
--- a/app/src/main/java/org/wikipedia/settings/
+++ b/app/src/main/java/org/wikipedia/settings/
@@ -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 @@
     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
To unsubscribe, visit

Gerrit-MessageType: merged
Gerrit-Change-Id: I01221423aab52f29a5a9066a7cbdbbc10e4f0c90
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Niedzielski <>
Gerrit-Reviewer: BearND <>
Gerrit-Reviewer: Brion VIBBER <>
Gerrit-Reviewer: Dbrant <>
Gerrit-Reviewer: Mholloway <>
Gerrit-Reviewer: jenkins-bot <>

MediaWiki-commits mailing list

Reply via email to