Niedzielski has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/316385

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(-)


  git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia 
refs/changes/85/316385/1

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: newchange
Gerrit-Change-Id: I01221423aab52f29a5a9066a7cbdbbc10e4f0c90
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Niedzielski <sniedziel...@wikimedia.org>

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

Reply via email to