Program: 19363
Project: 19363
Buggy source:
/** 
 * Checks that the correct listeners are called the correct number of times from all of our access and mutation operations.
 * @throws InterruptedException
 */
@Test public void testFilteredListener() throws InterruptedException {
  MyCacheEntryListener<Long,String> listener=new MyCacheEntryListener<Long,String>();
  CacheEntryEventFilter<Long,String> filter=new CacheEntryEventFilter<Long,String>(){
    @Override public boolean evaluate(    CacheEntryEvent<? extends Long,? extends String> event) throws CacheEntryListenerException {
      return event.getValue().contains("String_Node_Str") || event.getValue().contains("String_Node_Str") || event.getValue().contains("String_Node_Str")|| event.getValue().contains("String_Node_Str")|| event.getValue().contains("String_Node_Str");
    }
  }
;
  cache.registerCacheEntryListener(listener,false,filter,true);
  assertEquals(0,listener.getCreated());
  assertEquals(0,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(0,listener.getRemoved());
  cache.put(1l,"String_Node_Str");
  assertEquals(1,listener.getCreated());
  assertEquals(0,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(0,listener.getRemoved());
  Map<Long,String> entries=new HashMap<Long,String>();
  entries.put(2l,"String_Node_Str");
  entries.put(3l,"String_Node_Str");
  cache.putAll(entries);
  assertEquals(2,listener.getCreated());
  assertEquals(0,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(0,listener.getRemoved());
  cache.put(1l,"String_Node_Str");
  assertEquals(2,listener.getCreated());
  assertEquals(0,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(0,listener.getRemoved());
  cache.remove(2l);
  assertEquals(2,listener.getCreated());
  assertEquals(0,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(1,listener.getRemoved());
  cache.replace(1l,"String_Node_Str");
  assertEquals(2,listener.getCreated());
  assertEquals(1,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(1,listener.getRemoved());
  cache.replace(3l,"String_Node_Str","String_Node_Str");
  assertEquals(2,listener.getCreated());
  assertEquals(2,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(1,listener.getRemoved());
  cache.get(1L);
  assertEquals(2,listener.getCreated());
  assertEquals(2,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(1,listener.getRemoved());
  cache.containsKey(1L);
  assertEquals(2,listener.getCreated());
  assertEquals(2,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(1,listener.getRemoved());
  for (  Cache.Entry<Long,String> entry : cache) {
    String value=entry.getValue();
    System.out.println(value);
  }
  assertEquals(2,listener.getCreated());
  assertEquals(2,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(1,listener.getRemoved());
  cache.getAndPut(1l,"String_Node_Str");
  assertEquals(2,listener.getCreated());
  assertEquals(3,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(1,listener.getRemoved());
  Set<Long> keys=new HashSet<Long>();
  keys.add(1L);
  cache.getAll(keys);
  assertEquals(2,listener.getCreated());
  assertEquals(3,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(1,listener.getRemoved());
  cache.getAndReplace(1l,"String_Node_Str");
  assertEquals(2,listener.getCreated());
  assertEquals(4,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(1,listener.getRemoved());
  cache.getAndRemove(1l);
  assertEquals(2,listener.getCreated());
  assertEquals(4,listener.getUpdated());
  assertEquals(0,listener.getExpired());
  assertEquals(2,listener.getRemoved());
  Thread.sleep(50);
  assertEquals(null,cache.get(3L));
  assertEquals(2,listener.getCreated());
  assertEquals(4,listener.getUpdated());
  assertEquals(1,listener.getExpired());
  assertEquals(2,listener.getRemoved());
}

Fixed version (ground truth):
/** 
 * Checks that the correct listeners are called the correct number of times from all of our access and mutation operations.
 * @throws InterruptedException
 */
@Test public void testFilteredListener() throws InterruptedException {
  MyCacheEntryListener<Long,String> listener=new MyCacheEntryListener<Long,String>();
  CacheEntryEventFilter<Long,String> filter=new CacheEntryEventFilter<Long,String>(){
    @Override public boolean evaluate(    CacheEntryEvent<? extends Long,? extends String> event) throws CacheEntryListenerException {
      return event.getValue().contains("String_Node_Str") || event.getValue().contains("String_Node_Str") || event.getValue().contains("String_Node_Str")|| event.getValue().contains("String_Node_Str")|| event.getValue().contains("String_Node_Str");
    }
  }
;
  cache.registerCacheEntryListener(listener,false,filter,true);
  assertEquals(0,listener.getCreated());
  assertEquals(0,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  cache.put(1l,"String_Node_Str");
  assertEquals(1,listener.getCreated());
  assertEquals(0,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  Map<Long,String> entries=new HashMap<Long,String>();
  entries.put(2l,"String_Node_Str");
  entries.put(3l,"String_Node_Str");
  cache.putAll(entries);
  assertEquals(2,listener.getCreated());
  assertEquals(0,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  cache.put(1l,"String_Node_Str");
  assertEquals(2,listener.getCreated());
  assertEquals(0,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  cache.remove(2l);
  assertEquals(2,listener.getCreated());
  assertEquals(0,listener.getUpdated());
  assertEquals(1,listener.getRemoved());
  cache.replace(1l,"String_Node_Str");
  assertEquals(2,listener.getCreated());
  assertEquals(1,listener.getUpdated());
  assertEquals(1,listener.getRemoved());
  cache.replace(3l,"String_Node_Str","String_Node_Str");
  assertEquals(2,listener.getCreated());
  assertEquals(2,listener.getUpdated());
  assertEquals(1,listener.getRemoved());
  cache.get(1L);
  assertEquals(2,listener.getCreated());
  assertEquals(2,listener.getUpdated());
  assertEquals(1,listener.getRemoved());
  cache.containsKey(1L);
  assertEquals(2,listener.getCreated());
  assertEquals(2,listener.getUpdated());
  assertEquals(1,listener.getRemoved());
  for (  Cache.Entry<Long,String> entry : cache) {
    String value=entry.getValue();
    System.out.println(value);
  }
  assertEquals(2,listener.getCreated());
  assertEquals(2,listener.getUpdated());
  assertEquals(1,listener.getRemoved());
  cache.getAndPut(1l,"String_Node_Str");
  assertEquals(2,listener.getCreated());
  assertEquals(3,listener.getUpdated());
  assertEquals(1,listener.getRemoved());
  Set<Long> keys=new HashSet<Long>();
  keys.add(1L);
  cache.getAll(keys);
  assertEquals(2,listener.getCreated());
  assertEquals(3,listener.getUpdated());
  assertEquals(1,listener.getRemoved());
  cache.getAndReplace(1l,"String_Node_Str");
  assertEquals(2,listener.getCreated());
  assertEquals(4,listener.getUpdated());
  assertEquals(1,listener.getRemoved());
  cache.getAndRemove(1l);
  assertEquals(2,listener.getCreated());
  assertEquals(4,listener.getUpdated());
  assertEquals(2,listener.getRemoved());
  Thread.sleep(50);
  assertEquals(null,cache.get(3L));
  assertEquals(2,listener.getCreated());
  assertEquals(4,listener.getUpdated());
  assertEquals(2,listener.getRemoved());
}