Program: 17262
Project: 17262
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public V getAndReplace(K key,V value){
  checkStatusStarted();
  if (value == null) {
    throw new NullPointerException("String_Node_Str" + key);
  }
  long now=System.currentTimeMillis();
  V result;
  lockManager.lock(key);
  try {
    Object internalKey=keyConverter.toInternal(key);
    RICachedValue cachedValue=entries.get(internalKey);
    if (cachedValue == null || cachedValue.isExpiredAt(now)) {
      result=null;
    }
 else {
      RIEntry<K,V> entry=new RIEntry<K,V>(key,value);
      writeCacheEntry(entry);
      result=valueConverter.fromInternal(cachedValue.getInternalValue(now));
      Duration duration=expiryPolicy.getTTLForModifiedEntry(entry,new Duration(now,cachedValue.getExpiryTime()));
      long expiryTime=duration.getAdjustedTime(now);
      Object internalValue=valueConverter.toInternal(value);
      cachedValue.setInternalValue(internalValue,now);
      cachedValue.setExpiryTime(expiryTime);
      RICacheEventEventDispatcher<K,V> dispatcher=new RICacheEventEventDispatcher<K,V>();
      dispatcher.addEvent(CacheEntryUpdatedListener.class,new RICacheEntryEvent<K,V>(this,key,value,result));
      dispatcher.dispatch(cacheEntryListenerRegistrations.values());
    }
  }
  finally {
    lockManager.unLock(key);
  }
  if (statisticsEnabled()) {
    if (result != null) {
      statistics.increaseCacheHits(1);
      statistics.increaseCachePuts(1);
    }
 else {
      statistics.increaseCacheMisses(1);
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public V getAndReplace(K key,V value){
  checkStatusStarted();
  if (value == null) {
    throw new NullPointerException("String_Node_Str" + key);
  }
  long now=System.currentTimeMillis();
  V result;
  lockManager.lock(key);
  try {
    Object internalKey=keyConverter.toInternal(key);
    RICachedValue cachedValue=entries.get(internalKey);
    if (cachedValue == null || cachedValue.isExpiredAt(now)) {
      result=null;
    }
 else {
      RIEntry<K,V> entry=new RIEntry<K,V>(key,value);
      writeCacheEntry(entry);
      result=valueConverter.fromInternal(cachedValue.getInternalValue(now));
      Duration duration;
      try {
        duration=expiryPolicy.getTTLForModifiedEntry(entry,new Duration(now,cachedValue.getExpiryTime()));
      }
 catch (      Throwable t) {
        duration=getDefaultDuration();
      }
      long expiryTime=duration.getAdjustedTime(now);
      Object internalValue=valueConverter.toInternal(value);
      cachedValue.setInternalValue(internalValue,now);
      cachedValue.setExpiryTime(expiryTime);
      RICacheEventEventDispatcher<K,V> dispatcher=new RICacheEventEventDispatcher<K,V>();
      dispatcher.addEvent(CacheEntryUpdatedListener.class,new RICacheEntryEvent<K,V>(this,key,value,result));
      dispatcher.dispatch(cacheEntryListenerRegistrations.values());
    }
  }
  finally {
    lockManager.unLock(key);
  }
  if (statisticsEnabled()) {
    if (result != null) {
      statistics.increaseCacheHits(1);
      statistics.increaseCachePuts(1);
    }
 else {
      statistics.increaseCacheMisses(1);
    }
  }
  return result;
}