Program: 17288
Project: 17288
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void removeAll(){
  checkStatusStarted();
  int size=(statisticsEnabled()) ? entries.size() : 0;
  long now=System.currentTimeMillis();
  CacheException exception=null;
  HashSet<K> lockedKeys=new HashSet<K>();
  RICacheEventEventDispatcher<K,V> dispatcher=new RICacheEventEventDispatcher<K,V>();
  try {
    boolean isWriteThrough=configuration.isWriteThrough() && configuration.getCacheWriter() != null;
    HashSet<K> keysToDelete=new HashSet<K>();
    Iterator<Map.Entry<Object,RICachedValue>> iterator=entries.iterator();
    while (iterator.hasNext()) {
      Map.Entry<Object,RICachedValue> entry=iterator.next();
      Object internalKey=entry.getKey();
      K key=keyConverter.fromInternal(internalKey);
      lockManager.lock(key);
      lockedKeys.add(key);
      if (isWriteThrough) {
        keysToDelete.add(key);
      }
    }
    if (isWriteThrough) {
      try {
        CacheWriter<K,V> writer=(CacheWriter<K,V>)configuration.getCacheWriter();
        writer.deleteAll(keysToDelete);
      }
 catch (      CacheException e) {
        exception=e;
      }
    }
    for (    K key : lockedKeys) {
      if (!keysToDelete.contains(key)) {
        Object internalKey=keyConverter.toInternal(key);
        RICachedValue cachedValue=entries.remove(internalKey);
        V value=valueConverter.fromInternal(cachedValue.get());
        RICacheEntryEvent<K,V> event=new RICacheEntryEvent<K,V>(this,key,value);
        if (cachedValue.isExpiredAt(now)) {
          dispatcher.addEvent(CacheEntryExpiredListener.class,event);
        }
 else {
          dispatcher.addEvent(CacheEntryRemovedListener.class,event);
        }
      }
    }
  }
  finally {
    for (    K key : lockedKeys) {
      lockManager.unLock(key);
    }
  }
  dispatcher.dispatch(cacheEntryListenerRegistrations.values());
  if (statisticsEnabled()) {
    statistics.increaseCacheRemovals(size);
  }
  if (exception != null) {
    throw exception;
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void removeAll(){
  checkStatusStarted();
  int size=(statisticsEnabled()) ? entries.size() : 0;
  long now=System.currentTimeMillis();
  CacheException exception=null;
  HashSet<K> lockedKeys=new HashSet<K>();
  RICacheEventEventDispatcher<K,V> dispatcher=new RICacheEventEventDispatcher<K,V>();
  try {
    boolean isWriteThrough=configuration.isWriteThrough() && cacheWriter != null;
    HashSet<K> keysToDelete=new HashSet<K>();
    Iterator<Map.Entry<Object,RICachedValue>> iterator=entries.iterator();
    while (iterator.hasNext()) {
      Map.Entry<Object,RICachedValue> entry=iterator.next();
      Object internalKey=entry.getKey();
      K key=keyConverter.fromInternal(internalKey);
      lockManager.lock(key);
      lockedKeys.add(key);
      if (isWriteThrough) {
        keysToDelete.add(key);
      }
    }
    if (isWriteThrough) {
      try {
        cacheWriter.deleteAll(keysToDelete);
      }
 catch (      CacheException e) {
        exception=e;
      }
    }
    for (    K key : lockedKeys) {
      if (!keysToDelete.contains(key)) {
        Object internalKey=keyConverter.toInternal(key);
        RICachedValue cachedValue=entries.remove(internalKey);
        V value=valueConverter.fromInternal(cachedValue.get());
        RICacheEntryEvent<K,V> event=new RICacheEntryEvent<K,V>(this,key,value);
        if (cachedValue.isExpiredAt(now)) {
          dispatcher.addEvent(CacheEntryExpiredListener.class,event);
        }
 else {
          dispatcher.addEvent(CacheEntryRemovedListener.class,event);
        }
      }
    }
  }
  finally {
    for (    K key : lockedKeys) {
      lockManager.unLock(key);
    }
  }
  dispatcher.dispatch(cacheEntryListenerRegistrations.values());
  if (statisticsEnabled()) {
    statistics.increaseCacheRemovals(size);
  }
  if (exception != null) {
    throw exception;
  }
}