From d5bcb68cb7208ac9766570848c42a6e44e32dc10 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Sat, 9 Aug 2014 16:36:35 -0700 Subject: Use thread safe set for RemoteConnection.mListeners Switch from HashSet to set backed by a ConcurrentHashMap to prevent ConcurrentModificationExceptions. Bug: 16901565 Change-Id: I7666ef61e94994963b2c2634a9a250365e753888 --- telecomm/java/android/telecomm/RemoteConnection.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'telecomm') diff --git a/telecomm/java/android/telecomm/RemoteConnection.java b/telecomm/java/android/telecomm/RemoteConnection.java index 197e480..a8636d4 100644 --- a/telecomm/java/android/telecomm/RemoteConnection.java +++ b/telecomm/java/android/telecomm/RemoteConnection.java @@ -28,6 +28,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; /** * RemoteConnection object used by RemoteConnectionService. @@ -179,7 +180,8 @@ public final class RemoteConnection { private IConnectionService mConnectionService; private final String mConnectionId; - private final Set mListeners = new HashSet<>(); + private final Set mListeners = Collections.newSetFromMap( + new ConcurrentHashMap(2)); private final Set mConferenceableConnections = new HashSet<>(); private int mState = Connection.State.NEW; -- cgit v1.1