Skip to content

Commit

Permalink
ISPN-7070
Browse files Browse the repository at this point in the history
CacheNotifierImplInitialTransferDistTest.testIterationBeganAndSegmentNotComplete
random failures

* Make sure reads into listener collection are also synchronized
* Remove listener before replacing notifier that it registered with
  • Loading branch information
wburns authored and pruivo committed Feb 28, 2017
1 parent fec990b commit f219434
Showing 1 changed file with 4 additions and 3 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -660,12 +661,12 @@ private boolean isClustered(StateListener listener) {
}

protected static abstract class StateListener<K, V> {
final List<CacheEntryEvent<K, V>> events = new ArrayList<>();
final List<CacheEntryEvent<K, V>> events = Collections.synchronizedList(new ArrayList<>());

@CacheEntryCreated
@CacheEntryModified
@CacheEntryRemoved
public synchronized void onCacheNotification(CacheEntryEvent<K, V> event) {
public void onCacheNotification(CacheEntryEvent<K, V> event) {
events.add(event);
}
}
Expand Down

0 comments on commit f219434

Please sign in to comment.