Program: 17232
Project: 17232
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 {
      V oldValue=valueConverter.fromInternal(cachedValue.getInternalValue(now));
      RIEntry<K,V> entry=new RIEntry<K,V>(key,value,oldValue);
      writeCacheEntry(entry);
      try {
        Duration duration=expiryPolicy.getExpiryForModifiedEntry(key);
        if (duration != null) {
          long expiryTime=duration.getAdjustedTime(now);
          cachedValue.setExpiryTime(expiryTime);
        }
      }
 catch (      Throwable t) {
      }
      Object internalValue=valueConverter.toInternal(value);
      cachedValue.setInternalValue(internalValue,now);
      RICacheEventDispatcher<K,V> dispatcher=new RICacheEventDispatcher<K,V>();
      dispatcher.addEvent(CacheEntryUpdatedListener.class,new RICacheEntryEvent<K,V>(this,key,value,oldValue,UPDATED));
      dispatcher.dispatch(listenerRegistrations);
      result=oldValue;
    }
  }
  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.getExpiryForUpdate();
        if (duration != null) {
          long expiryTime=duration.getAdjustedTime(now);
          cachedValue.setExpiryTime(expiryTime);
        }
      }
 catch (      Throwable t) {
      }
      Object internalValue=valueConverter.toInternal(value);
      cachedValue.setInternalValue(internalValue,now);
      RICacheEventDispatcher<K,V> dispatcher=new RICacheEventDispatcher<K,V>();
      dispatcher.addEvent(CacheEntryUpdatedListener.class,new RICacheEntryEvent<K,V>(this,key,value,oldValue,UPDATED));
      dispatcher.dispatch(listenerRegistrations);
      result=oldValue;
    }
  }
  finally {
    lockManager.unLock(key);
  }
  if (statisticsEnabled()) {
    if (result != null) {
      statistics.increaseCacheHits(1);
      statistics.increaseCachePuts(1);
    }
 else {
      statistics.increaseCacheMisses(1);
    }
  }
  return result;
}