Committed by
Gerrit Code Review
Fix synchronization issue
- synchronizedMultiMaps needs to be synchronized, when iterating over it's contents. See: http://static.javadoc.io/com.google.guava/guava/18.0/com/google/common/collect/Multimaps.html#synchronizedMultimap(com.google.common.collect.Multimap) Change-Id: I398079a67e9fab58edc9d6f0295169939e640ba2
Showing
2 changed files
with
10 additions
and
2 deletions
... | @@ -375,7 +375,12 @@ public class ObjectiveTracker implements ObjectiveTrackerService { | ... | @@ -375,7 +375,12 @@ public class ObjectiveTracker implements ObjectiveTrackerService { |
375 | } | 375 | } |
376 | 376 | ||
377 | // TODO should we recompile on available==true? | 377 | // TODO should we recompile on available==true? |
378 | - delegate.triggerCompile(ImmutableSet.copyOf(intentsByDevice.get(id)), available); | 378 | + |
379 | + final ImmutableSet<Key> snapshot; | ||
380 | + synchronized (intentsByDevice) { | ||
381 | + snapshot = ImmutableSet.copyOf(intentsByDevice.get(id)); | ||
382 | + } | ||
383 | + delegate.triggerCompile(snapshot, available); | ||
379 | } | 384 | } |
380 | } | 385 | } |
381 | 386 | ... | ... |
... | @@ -443,7 +443,10 @@ public class DatabaseManager implements StorageService, StorageAdminService { | ... | @@ -443,7 +443,10 @@ public class DatabaseManager implements StorageService, StorageAdminService { |
443 | public void event(ApplicationEvent event) { | 443 | public void event(ApplicationEvent event) { |
444 | if (event.type() == APP_UNINSTALLED || event.type() == APP_DEACTIVATED) { | 444 | if (event.type() == APP_UNINSTALLED || event.type() == APP_DEACTIVATED) { |
445 | ApplicationId appId = event.subject().id(); | 445 | ApplicationId appId = event.subject().id(); |
446 | - List<DefaultAsyncConsistentMap> mapsToRemove = ImmutableList.copyOf(mapsByApplication.get(appId)); | 446 | + List<DefaultAsyncConsistentMap> mapsToRemove; |
447 | + synchronized (mapsByApplication) { | ||
448 | + mapsToRemove = ImmutableList.copyOf(mapsByApplication.get(appId)); | ||
449 | + } | ||
447 | mapsToRemove.forEach(DatabaseManager.this::unregisterMap); | 450 | mapsToRemove.forEach(DatabaseManager.this::unregisterMap); |
448 | if (event.type() == APP_UNINSTALLED) { | 451 | if (event.type() == APP_UNINSTALLED) { |
449 | mapsToRemove.stream().filter(map -> map.purgeOnUninstall()).forEach(map -> map.clear()); | 452 | mapsToRemove.stream().filter(map -> map.purgeOnUninstall()).forEach(map -> map.clear()); | ... | ... |
-
Please register or login to post a comment