Program: 17318
Project: 17318
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public V getAndReplace(K key,V value){
  ensureOpen();
  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));
      try {
        Duration duration=expiryPolicy.getTTLForModifiedEntry(entry,new Duration(now,cachedValue.getExpiryTime()));
        long expiryTime=duration.getAdjustedTime(now);
        cachedValue.setExpiryTime(expiryTime);
      }
 catch (      Throwable t) {
      }
      Object internalValue=valueConverter.toInternal(value);
      cachedValue.setInternalValue(internalValue,now);
      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){
  ensureOpen();
  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 {
      V oldValue=valueConverter.fromInternal(cachedValue.getInternalValue(now));
      RIEntry<K,V> entry=new RIEntry<K,V>(key,value,oldValue);
      writeCacheEntry(entry);
      try {
        Duration duration=expiryPolicy.getTTLForModifiedEntry(entry,new Duration(now,cachedValue.getExpiryTime()));
        long expiryTime=duration.getAdjustedTime(now);
        cachedValue.setExpiryTime(expiryTime);
      }
 catch (      Throwable t) {
      }
      Object internalValue=valueConverter.toInternal(value);
      cachedValue.setInternalValue(internalValue,now);
      RICacheEventEventDispatcher<K,V> dispatcher=new RICacheEventEventDispatcher<K,V>();
      dispatcher.addEvent(CacheEntryUpdatedListener.class,new RICacheEntryEvent<K,V>(this,key,value,oldValue));
      dispatcher.dispatch(cacheEntryListenerRegistrations.values());
      result=oldValue;
    }
  }
  finally {
    lockManager.unLock(key);
  }
  if (statisticsEnabled()) {
    if (result != null) {
      statistics.increaseCacheHits(1);
      statistics.increaseCachePuts(1);
    }
 else {
      statistics.increaseCacheMisses(1);
    }
  }
  return result;
}