Program: 17338
Project: 17338
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public <T>T invokeEntryProcessor(K key,EntryProcessor<K,V,T> entryProcessor,Object... arguments){
  ensureOpen();
  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:
V oldValue=valueConverter.fromInternal(cachedValue.get());
e=new RIEntry<K,V>(key,entry.value,oldValue);
writeCacheEntry(e);
try {
duration=expiryPolicy.getTTLForModifiedEntry(e,new Duration(now,cachedValue.getExpiryTime()));
expiryTime=duration.getAdjustedTime(now);
cachedValue.setExpiryTime(expiryTime);
}
 catch (Throwable t) {
}
cachedValue.setInternalValue(valueConverter.toInternal(entry.value),now);
dispatcher.addEvent(CacheEntryUpdatedListener.class,new RICacheEntryEvent<K,V>(this,key,entry.value,oldValue));
if (statisticsEnabled()) {
statistics.increaseCachePuts(1);
statistics.addPutTimeNano(System.nanoTime() - start);
}
break;
case REMOVE:
deleteCacheEntry(key);
oldValue=valueConverter.fromInternal(cachedValue.get());
entries.remove(internalKey);
dispatcher.addEvent(CacheEntryRemovedListener.class,new RICacheEntryEvent<K,V>(this,key,oldValue));
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){
  ensureOpen();
  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:
V oldValue=valueConverter.fromInternal(cachedValue.get());
e=new RIEntry<K,V>(key,entry.value,oldValue);
writeCacheEntry(e);
try {
duration=expiryPolicy.getTTLForModifiedEntry(e);
if (duration != null) {
expiryTime=duration.getAdjustedTime(now);
cachedValue.setExpiryTime(expiryTime);
}
}
 catch (Throwable t) {
}
cachedValue.setInternalValue(valueConverter.toInternal(entry.value),now);
dispatcher.addEvent(CacheEntryUpdatedListener.class,new RICacheEntryEvent<K,V>(this,key,entry.value,oldValue));
if (statisticsEnabled()) {
statistics.increaseCachePuts(1);
statistics.addPutTimeNano(System.nanoTime() - start);
}
break;
case REMOVE:
deleteCacheEntry(key);
oldValue=valueConverter.fromInternal(cachedValue.get());
entries.remove(internalKey);
dispatcher.addEvent(CacheEntryRemovedListener.class,new RICacheEntryEvent<K,V>(this,key,oldValue));
if (statisticsEnabled()) {
statistics.increaseCacheRemovals(1);
statistics.addRemoveTimeNano(System.nanoTime() - start);
}
break;
default :
break;
}
dispatcher.dispatch(cacheEntryListenerRegistrations.values());
}
  finally {
lockManager.unLock(key);
}
return result;
}