Skip to content

Commit 6ed40df

Browse files
authored
Fix VarCache.variants thread-safety (#441)
* Fix thread-safety of VarCache.variants * Improve parity of initializations
1 parent 73ac180 commit 6ed40df

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

AndroidSDKCore/src/main/java/com/leanplum/internal/VarCache.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public class VarCache {
7676
private static Map<String, Object> devModeValuesFromServer;
7777
private static Map<String, Object> devModeFileAttributesFromServer;
7878
private static Map<String, Object> devModeActionDefinitionsFromServer;
79-
private static List<Map<String, Object>> variants = new ArrayList<>();
79+
private static volatile List<Map<String, Object>> variants = new ArrayList<>();
8080
private static CacheUpdateBlock updateBlock;
8181
private static boolean hasReceivedDiffs = false;
8282
private static Map<String, Object> messages = new HashMap<>();
@@ -874,7 +874,7 @@ public static void saveUserAttributes() {
874874

875875
public static void clearUserContent() {
876876
vars.clear();
877-
variants.clear();
877+
variants = new ArrayList<>();
878878
variantDebugInfo.clear();
879879

880880
diffs.clear();
@@ -905,7 +905,7 @@ public static void reset() {
905905
devModeValuesFromServer = null;
906906
devModeFileAttributesFromServer = null;
907907
devModeActionDefinitionsFromServer = null;
908-
variants.clear();
908+
variants = new ArrayList<>();
909909
updateBlock = null;
910910
hasReceivedDiffs = false;
911911
messages = null;

0 commit comments

Comments
 (0)