Program: 19319
Project: 19319
Buggy source:
/** 
 * Check the listener is getting reads
 */
@Test public void testCacheEntryListener(){
  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(3,listener.getCreated());
  assertEquals(0,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  cache.put(1l,"String_Node_Str");
  assertEquals(3,listener.getCreated());
  assertEquals(1,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  cache.putAll(entries);
  assertEquals(3,listener.getCreated());
  assertEquals(3,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  cache.getAndPut(4l,"String_Node_Str");
  assertEquals(4,listener.getCreated());
  assertEquals(3,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  cache.getAndPut(4l,"String_Node_Str");
  assertEquals(4,listener.getCreated());
  assertEquals(4,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  String value=cache.get(1l);
  assertEquals(4,listener.getCreated());
  assertEquals(4,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  EntryProcessor<Long,String,String> multiArgEP=new MultiArgumentHandlingEntryProcessor<>(value);
  String result=cache.invoke(1l,multiArgEP,"String_Node_Str","String_Node_Str","String_Node_Str",1l);
  assertEquals(value,result);
  assertEquals(4,listener.getCreated());
  assertEquals(4,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  result=cache.invoke(1l,new SetEntryProcessor<Long,String,String>("String_Node_Str"));
  assertEquals("String_Node_Str",result);
  assertEquals(4,listener.getCreated());
  assertEquals(5,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  result=cache.invoke(1l,new RemoveEntryProcessor<Long,String,String>());
  assertNull(result);
  assertEquals(4,listener.getCreated());
  assertEquals(5,listener.getUpdated());
  assertEquals(1,listener.getRemoved());
  result=cache.invoke(1l,new SetEntryProcessor<Long,String,String>("String_Node_Str"));
  assertEquals("String_Node_Str",result);
  assertEquals(5,listener.getCreated());
  assertEquals(5,listener.getUpdated());
  assertEquals(1,listener.getRemoved());
  Iterator<Cache.Entry<Long,String>> iterator=cache.iterator();
  while (iterator.hasNext()) {
    iterator.next();
    iterator.remove();
  }
  assertEquals(5,listener.getCreated());
  assertEquals(5,listener.getUpdated());
  assertEquals(5,listener.getRemoved());
}

Fixed version (ground truth):
/** 
 * Check the listener is getting reads
 */
@Test public void testCacheEntryListener(){
  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(3,listener.getCreated());
  assertEquals(0,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  cache.put(1l,"String_Node_Str");
  assertEquals(3,listener.getCreated());
  assertEquals(1,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  cache.putAll(entries);
  assertEquals(3,listener.getCreated());
  assertEquals(3,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  cache.getAndPut(4l,"String_Node_Str");
  assertEquals(4,listener.getCreated());
  assertEquals(3,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  cache.getAndPut(4l,"String_Node_Str");
  assertEquals(4,listener.getCreated());
  assertEquals(4,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  String value=cache.get(1l);
  assertEquals(4,listener.getCreated());
  assertEquals(4,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  EntryProcessor<Long,String,String> multiArgEP=new MultiArgumentHandlingEntryProcessor<>(value);
  String result=cache.invoke(1l,multiArgEP,"String_Node_Str","String_Node_Str","String_Node_Str",1l);
  assertEquals(value,result);
  assertEquals(4,listener.getCreated());
  assertEquals(4,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  result=cache.invoke(1l,new SetEntryProcessor<Long,String>("String_Node_Str"));
  assertEquals("String_Node_Str",result);
  assertEquals(4,listener.getCreated());
  assertEquals(5,listener.getUpdated());
  assertEquals(0,listener.getRemoved());
  result=cache.invoke(1l,new RemoveEntryProcessor<Long,String,String>());
  assertNull(result);
  assertEquals(4,listener.getCreated());
  assertEquals(5,listener.getUpdated());
  assertEquals(1,listener.getRemoved());
  result=cache.invoke(1l,new SetEntryProcessor<Long,String>("String_Node_Str"));
  assertEquals("String_Node_Str",result);
  assertEquals(5,listener.getCreated());
  assertEquals(5,listener.getUpdated());
  assertEquals(1,listener.getRemoved());
  Iterator<Cache.Entry<Long,String>> iterator=cache.iterator();
  while (iterator.hasNext()) {
    iterator.next();
    iterator.remove();
  }
  assertEquals(5,listener.getCreated());
  assertEquals(5,listener.getUpdated());
  assertEquals(5,listener.getRemoved());
}