Fix ConcurrentModificationException by locking mSubscribers access.
Bug: 142805004
Test: atest AndroidCarApiTest CarServiceTest CarServiceUnitTest
Change-Id: I084941d96c955af5f77049d3c05516fc995314a2
diff --git a/service/src/com/android/car/vms/VmsClientManager.java b/service/src/com/android/car/vms/VmsClientManager.java
index a00e179..66a0fe4 100644
--- a/service/src/com/android/car/vms/VmsClientManager.java
+++ b/service/src/com/android/car/vms/VmsClientManager.java
@@ -286,9 +286,11 @@
* Returns all active subscriber clients.
*/
public Collection<IVmsSubscriberClient> getAllSubscribers() {
- return mSubscribers.values().stream()
- .map(subscriber -> subscriber.mClient)
- .collect(Collectors.toList());
+ synchronized (mLock) {
+ return mSubscribers.values().stream()
+ .map(subscriber -> subscriber.mClient)
+ .collect(Collectors.toList());
+ }
}
/**