Program: 17261
Project: 17261
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public <T>T invokeEntryProcessor(K key,EntryProcessor<K,V,T> entryProcessor,Object... arguments){
  checkStatusStarted();
  if (key == null) {
    throw new NullPointerException();
  }
  if (entryProcessor == null) {
    throw new NullPointerException();
  }
  long start=statisticsEnabled() ? System.nanoTime() : 0;
  T result=null;
  lockManager.lock(key);
  try {
    long now=System.currentTimeMillis();
    RICacheEventEventDispatcher<K,V> dispatcher=new RICacheEventEventDispatcher<K,V>();
    Object internalKey=keyConverter.toInternal(key);
    RICachedValue cachedValue=entries.get(internalKey);
    if (statisticsEnabled()) {
      if (cachedValue == null) {
        statistics.increaseCacheMisses(1);
      }
 else {
        statistics.increaseCacheHits(1);
      }
    }
    if (statisticsEnabled()) {
      statistics.addGetTimeNano(System.nanoTime() - start);
    }
    start=statisticsEnabled() ? System.nanoTime() : 0;
    EntryProcessorEntry entry=new EntryProcessorEntry(key,cachedValue,now,dispatcher);
    try {
      result=entryProcessor.process(entry,arguments);
    }
 catch (    Throwable t) {
      throw new CacheException(t);
    }
    Duration duration;
    long expiryTime;
switch (entry.operation) {
case NONE:
      break;
case CREATE:
    RIEntry<K,V> e=new RIEntry<K,V>(key,entry.value);
  writeCacheEntry(e);
duration=expiryPolicy.getTTLForCreatedEntry(e);
expiryTime=duration.getAdjustedTime(now);
cachedValue=new RICachedValue(valueConverter.toInternal(entry.value),now,expiryTime);
if (cachedValue.isExpiredAt(now)) {
V previousValue=valueConverter.fromInternal(cachedValue.get());
dispatcher.addEvent(CacheEntryExpiredListener.class,new RICacheEntryEvent<K,V>(this,key,previousValue));
}
entries.put(internalKey,cachedValue);
dispatcher.addEvent(CacheEntryCreatedListener.class,new RICacheEntryEvent<K,V>(this,key,entry.value));
if (statisticsEnabled()) {
statistics.increaseCachePuts(1);
statistics.addPutTimeNano(System.nanoTime() - start);
}
break;
case UPDATE:
e=new RIEntry<K,V>(key,entry.value);
writeCacheEntry(e);
duration=expiryPolicy.getTTLForModifiedEntry(e,new Duration(now,cachedValue.getExpiryTime()));
expiryTime=duration.getAdjustedTime(now);
V previousValue=valueConverter.fromInternal(cachedValue.get());
cachedValue.setInternalValue(valueConverter.toInternal(entry.value),now);
cachedValue.setExpiryTime(expiryTime);
dispatcher.addEvent(CacheEntryUpdatedListener.class,new RICacheEntryEvent<K,V>(this,key,entry.value,previousValue));
if (statisticsEnabled()) {
statistics.increaseCachePuts(1);
statistics.addPutTimeNano(System.nanoTime() - start);
}
break;
case REMOVE:
deleteCacheEntry(key);
previousValue=valueConverter.fromInternal(cachedValue.get());
entries.remove(internalKey);
dispatcher.addEvent(CacheEntryRemovedListener.class,new RICacheEntryEvent<K,V>(this,key,previousValue));
if (statisticsEnabled()) {
statistics.increaseCacheRemovals(1);
statistics.addRemoveTimeNano(System.nanoTime() - start);
}
break;
default :
break;
}
dispatcher.dispatch(cacheEntryListenerRegistrations.values());
}
  finally {
lockManager.unLock(key);
}
return result;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public <T>T invokeEntryProcessor(K key,EntryProcessor<K,V,T> entryProcessor,Object... arguments){
  checkStatusStarted();
  if (key == null) {
    throw new NullPointerException();
  }
  if (entryProcessor == null) {
    throw new NullPointerException();
  }
  long start=statisticsEnabled() ? System.nanoTime() : 0;
  T result=null;
  lockManager.lock(key);
  try {
    long now=System.currentTimeMillis();
    RICacheEventEventDispatcher<K,V> dispatcher=new RICacheEventEventDispatcher<K,V>();
    Object internalKey=keyConverter.toInternal(key);
    RICachedValue cachedValue=entries.get(internalKey);
    if (statisticsEnabled()) {
      if (cachedValue == null) {
        statistics.increaseCacheMisses(1);
      }
 else {
        statistics.increaseCacheHits(1);
      }
    }
    if (statisticsEnabled()) {
      statistics.addGetTimeNano(System.nanoTime() - start);
    }
    start=statisticsEnabled() ? System.nanoTime() : 0;
    EntryProcessorEntry entry=new EntryProcessorEntry(key,cachedValue,now,dispatcher);
    try {
      result=entryProcessor.process(entry,arguments);
    }
 catch (    Throwable t) {
      throw new CacheException(t);
    }
    Duration duration;
    long expiryTime;
switch (entry.operation) {
case NONE:
      break;
case CREATE:
    RIEntry<K,V> e=new RIEntry<K,V>(key,entry.value);
  writeCacheEntry(e);
try {
  duration=expiryPolicy.getTTLForCreatedEntry(e);
}
 catch (Throwable t) {
  duration=getDefaultDuration();
}
expiryTime=duration.getAdjustedTime(now);
cachedValue=new RICachedValue(valueConverter.toInternal(entry.value),now,expiryTime);
if (cachedValue.isExpiredAt(now)) {
V previousValue=valueConverter.fromInternal(cachedValue.get());
dispatcher.addEvent(CacheEntryExpiredListener.class,new RICacheEntryEvent<K,V>(this,key,previousValue));
}
entries.put(internalKey,cachedValue);
dispatcher.addEvent(CacheEntryCreatedListener.class,new RICacheEntryEvent<K,V>(this,key,entry.value));
if (statisticsEnabled()) {
statistics.increaseCachePuts(1);
statistics.addPutTimeNano(System.nanoTime() - start);
}
break;
case UPDATE:
e=new RIEntry<K,V>(key,entry.value);
writeCacheEntry(e);
try {
duration=expiryPolicy.getTTLForModifiedEntry(e,new Duration(now,cachedValue.getExpiryTime()));
}
 catch (Throwable t) {
duration=getDefaultDuration();
}
expiryTime=duration.getAdjustedTime(now);
V previousValue=valueConverter.fromInternal(cachedValue.get());
cachedValue.setInternalValue(valueConverter.toInternal(entry.value),now);
cachedValue.setExpiryTime(expiryTime);
dispatcher.addEvent(CacheEntryUpdatedListener.class,new RICacheEntryEvent<K,V>(this,key,entry.value,previousValue));
if (statisticsEnabled()) {
statistics.increaseCachePuts(1);
statistics.addPutTimeNano(System.nanoTime() - start);
}
break;
case REMOVE:
deleteCacheEntry(key);
previousValue=valueConverter.fromInternal(cachedValue.get());
entries.remove(internalKey);
dispatcher.addEvent(CacheEntryRemovedListener.class,new RICacheEntryEvent<K,V>(this,key,previousValue));
if (statisticsEnabled()) {
statistics.increaseCacheRemovals(1);
statistics.addRemoveTimeNano(System.nanoTime() - start);
}
break;
default :
break;
}
dispatcher.dispatch(cacheEntryListenerRegistrations.values());
}
  finally {
lockManager.unLock(key);
}
return result;
}