Committed by
Yuta HIGUCHI
Use concurrent hash map to avoid concurrent modification exceptions
Change-Id: I4d75d2304ae38eddded8b7ddf89a38ae6509af49
Showing
2 changed files
with
5 additions
and
3 deletions
... | @@ -19,6 +19,7 @@ import io.atomix.copycat.client.CopycatClient; | ... | @@ -19,6 +19,7 @@ import io.atomix.copycat.client.CopycatClient; |
19 | import io.atomix.resource.AbstractResource; | 19 | import io.atomix.resource.AbstractResource; |
20 | import io.atomix.resource.ResourceTypeInfo; | 20 | import io.atomix.resource.ResourceTypeInfo; |
21 | 21 | ||
22 | +import java.util.concurrent.ConcurrentHashMap; | ||
22 | import java.util.Collection; | 23 | import java.util.Collection; |
23 | import java.util.ConcurrentModificationException; | 24 | import java.util.ConcurrentModificationException; |
24 | import java.util.List; | 25 | import java.util.List; |
... | @@ -56,8 +57,8 @@ import org.onosproject.store.service.MapEvent; | ... | @@ -56,8 +57,8 @@ import org.onosproject.store.service.MapEvent; |
56 | import org.onosproject.store.service.MapEventListener; | 57 | import org.onosproject.store.service.MapEventListener; |
57 | import org.onosproject.store.service.MapTransaction; | 58 | import org.onosproject.store.service.MapTransaction; |
58 | import org.onosproject.store.service.Versioned; | 59 | import org.onosproject.store.service.Versioned; |
60 | + | ||
59 | import com.google.common.collect.ImmutableSet; | 61 | import com.google.common.collect.ImmutableSet; |
60 | -import com.google.common.collect.Maps; | ||
61 | import com.google.common.collect.Sets; | 62 | import com.google.common.collect.Sets; |
62 | 63 | ||
63 | /** | 64 | /** |
... | @@ -68,7 +69,7 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> | ... | @@ -68,7 +69,7 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> |
68 | implements AsyncConsistentMap<String, byte[]> { | 69 | implements AsyncConsistentMap<String, byte[]> { |
69 | 70 | ||
70 | private final Set<Consumer<Status>> statusChangeListeners = Sets.newCopyOnWriteArraySet(); | 71 | private final Set<Consumer<Status>> statusChangeListeners = Sets.newCopyOnWriteArraySet(); |
71 | - private final Map<MapEventListener<String, byte[]>, Executor> mapEventListeners = Maps.newIdentityHashMap(); | 72 | + private final Map<MapEventListener<String, byte[]>, Executor> mapEventListeners = new ConcurrentHashMap<>(); |
72 | 73 | ||
73 | public static final String CHANGE_SUBJECT = "changeEvents"; | 74 | public static final String CHANGE_SUBJECT = "changeEvents"; |
74 | 75 | ||
... | @@ -316,4 +317,4 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> | ... | @@ -316,4 +317,4 @@ public class AtomixConsistentMap extends AbstractResource<AtomixConsistentMap> |
316 | private boolean isListening() { | 317 | private boolean isListening() { |
317 | return !mapEventListeners.isEmpty(); | 318 | return !mapEventListeners.isEmpty(); |
318 | } | 319 | } |
319 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
320 | +} | ... | ... |
... | @@ -40,6 +40,7 @@ import org.onosproject.store.primitives.resources.impl.AtomixLeaderElectorComman | ... | @@ -40,6 +40,7 @@ import org.onosproject.store.primitives.resources.impl.AtomixLeaderElectorComman |
40 | import org.onosproject.store.primitives.resources.impl.AtomixLeaderElectorCommands.Unlisten; | 40 | import org.onosproject.store.primitives.resources.impl.AtomixLeaderElectorCommands.Unlisten; |
41 | import org.onosproject.store.primitives.resources.impl.AtomixLeaderElectorCommands.Withdraw; | 41 | import org.onosproject.store.primitives.resources.impl.AtomixLeaderElectorCommands.Withdraw; |
42 | import org.onosproject.store.service.AsyncLeaderElector; | 42 | import org.onosproject.store.service.AsyncLeaderElector; |
43 | + | ||
43 | import com.google.common.collect.ImmutableSet; | 44 | import com.google.common.collect.ImmutableSet; |
44 | import com.google.common.cache.CacheBuilder; | 45 | import com.google.common.cache.CacheBuilder; |
45 | import com.google.common.cache.CacheLoader; | 46 | import com.google.common.cache.CacheLoader; | ... | ... |
-
Please register or login to post a comment