Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
missing synchronization fix
Browse files Browse the repository at this point in the history
Bugfix 2622197.

Modification of the static mListeners (hashmap) is synchronized on the ContactsCache
class object.  This was missing, however, when we clone the hashmap in order to
send out updates.  Cloning is done in case the callback modifies the list of listeners.

Change-Id: Ic09aaee91e448c4a7d610b6f72ad8122fefef7da
  • Loading branch information
Mark Wagner committed Apr 27, 2010
1 parent 6bbfd94 commit 5e1e905
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/com/android/mms/data/Contact.java
Expand Up @@ -523,7 +523,12 @@ private void updateContact(final Contact c) {

// clone the list of listeners in case the onUpdate call turns around and
// modifies the list of listeners
for (UpdateListener l : (HashSet<UpdateListener>)Contact.mListeners.clone()) {
// access to mListeners is synchronized on ContactsCache
HashSet<UpdateListener> iterator;
synchronized (ContactsCache.class) {
iterator = (HashSet<UpdateListener>)Contact.mListeners.clone();
}
for (UpdateListener l : iterator) {
if (V) Log.d(TAG, "updating " + l);
l.onUpdate(c);
}
Expand Down

0 comments on commit 5e1e905

Please sign in to comment.