Commit b083d66b authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

Android: Replace ConcurrentHashMap usage with Collections.synchronizedMap()

ConcurrentHashMap has a bug on L.
Also adds a checkstyle check to prevent future uses.

Bug: 905903
Change-Id: Ic6afed17b5d7d3c6a150935117fb33e0408955e4
Reviewed-on: https://chromium-review.googlesource.com/c/1407493Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Commit-Queue: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#622143}
parent 0fdc21d5
...@@ -21,9 +21,10 @@ import java.lang.reflect.InvocationTargetException; ...@@ -21,9 +21,10 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Proxy; import java.lang.reflect.Proxy;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* Provides information about the current activity's status, and a way * Provides information about the current activity's status, and a way
...@@ -87,7 +88,8 @@ public class ApplicationStatus { ...@@ -87,7 +88,8 @@ public class ApplicationStatus {
/** /**
* A map of which observers listen to state changes from which {@link Activity}. * A map of which observers listen to state changes from which {@link Activity}.
*/ */
private static final Map<Activity, ActivityInfo> sActivityInfo = new ConcurrentHashMap<>(); private static final Map<Activity, ActivityInfo> sActivityInfo =
Collections.synchronizedMap(new HashMap<Activity, ActivityInfo>());
/** /**
* A list of observers to be notified when any {@link Activity} has a state change. * A list of observers to be notified when any {@link Activity} has a state change.
......
...@@ -126,5 +126,12 @@ ...@@ -126,5 +126,12 @@
<property name="ignoreComments" value="true"/> <property name="ignoreComments" value="true"/>
<property name="message" value="Use ContextUtils.getAppSharedPreferences() instead to access app-wide SharedPreferences."/> <property name="message" value="Use ContextUtils.getAppSharedPreferences() instead to access app-wide SharedPreferences."/>
</module> </module>
<module name="RegexpSinglelineJava">
<property name="id" value="ConcurrentHashMapCheck"/>
<property name="severity" value="error"/>
<property name="format" value="ConcurrentHashMap"/>
<property name="ignoreComments" value="true"/>
<property name="message" value="ConcurrentHashMap has a bug on some Android versions. Use Collections.synchronizedMap() instead (crbug.com/905903)."/>
</module>
</module> </module>
</module> </module>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment