diff options
author | Jason Chiu <chiujason@google.com> | 2020-07-01 17:18:29 +0800 |
---|---|---|
committer | Jason Chiu <chiujason@google.com> | 2020-07-01 10:42:25 +0000 |
commit | ea689abbcd16363fccde246b61b4e5ebf896902a (patch) | |
tree | 2ca705a0155d2648cda7e9488bc1c76b288884cf /src/com/android/settings | |
parent | f002dd72ac526f24a69c1fdfb9a15562ff0204ad (diff) | |
download | packages_apps_Settings-ea689abbcd16363fccde246b61b4e5ebf896902a.tar.gz packages_apps_Settings-ea689abbcd16363fccde246b61b4e5ebf896902a.tar.bz2 packages_apps_Settings-ea689abbcd16363fccde246b61b4e5ebf896902a.zip |
Fix the exception of accessing an ArrayMap
- ArrayMap is not thread-safe.
- When accessing the map across threads at the same time, the map may
throw a ConcurrentModificationException.
- Convert the map to a synchronizedMap to avoid the exception.
Fixes: 159813482
Test: robotest
Change-Id: I3b8bdd435c7c546acf736fa8aafd2ceaed94d081
Diffstat (limited to 'src/com/android/settings')
-rw-r--r-- | src/com/android/settings/slices/SliceBackgroundWorker.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/com/android/settings/slices/SliceBackgroundWorker.java b/src/com/android/settings/slices/SliceBackgroundWorker.java index 6eb154e955..2b029999ef 100644 --- a/src/com/android/settings/slices/SliceBackgroundWorker.java +++ b/src/com/android/settings/slices/SliceBackgroundWorker.java @@ -33,6 +33,7 @@ import java.io.Closeable; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -190,7 +191,8 @@ public abstract class SliceBackgroundWorker<E> implements Closeable { private static NotifySliceChangeHandler sHandler; - private final Map<Uri, Long> mLastUpdateTimeLookup = new ArrayMap<>(); + private final Map<Uri, Long> mLastUpdateTimeLookup = Collections.synchronizedMap( + new ArrayMap<>()); private static NotifySliceChangeHandler getInstance() { if (sHandler == null) { |