diff --git a/core/src/test/java/org/infinispan/notifications/cachelistener/CacheNotifierImplInitialTransferDistTest.java b/core/src/test/java/org/infinispan/notifications/cachelistener/CacheNotifierImplInitialTransferDistTest.java index 615be7c9049..8ce146c2aeb 100644 --- a/core/src/test/java/org/infinispan/notifications/cachelistener/CacheNotifierImplInitialTransferDistTest.java +++ b/core/src/test/java/org/infinispan/notifications/cachelistener/CacheNotifierImplInitialTransferDistTest.java @@ -13,6 +13,7 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -583,9 +584,9 @@ public Void call() throws Exception { assertEquals(event.getValue(), value); } } finally { + cache.removeListener(listener); TestingUtil.replaceComponent(cache, CacheNotifier.class, notifier, true); TestingUtil.replaceComponent(cache, ClusterCacheNotifier.class, notifier, true); - cache.removeListener(listener); } } @@ -660,12 +661,12 @@ private boolean isClustered(StateListener listener) { } protected static abstract class StateListener { - final List> events = new ArrayList<>(); + final List> events = Collections.synchronizedList(new ArrayList<>()); @CacheEntryCreated @CacheEntryModified @CacheEntryRemoved - public synchronized void onCacheNotification(CacheEntryEvent event) { + public void onCacheNotification(CacheEntryEvent event) { events.add(event); } }