nus-yam/ex-repair huggingface dataset:
Program: 17219
Project: 17219
Buggy source:
/** 
 * Releases the CacheManager with the specified URI and ClassLoader from this CachingProvider.  This does not close the CacheManager.  It simply releases it from being tracked by the CachingProvider. <p/> This method does nothing if a CacheManager matching the specified parameters is not being tracked.
 * @param uri         the URI of the CacheManager
 * @param classLoader the ClassLoader of the CacheManager
 */
public synchronized void releaseCacheManager(URI uri,ClassLoader classLoader){
  URI managerURI=uri == null ? getDefaultURI() : uri;
  ClassLoader managerClassLoader=classLoader == null ? getDefaultClassLoader() : classLoader;
  HashMap<URI,CacheManager> cacheManagersByURI=cacheManagersByClassLoader.get(managerClassLoader);
  if (cacheManagersByURI != null) {
    cacheManagersByURI.remove(managerURI);
    if (cacheManagersByURI.size() == 0) {
      cacheManagersByClassLoader.remove(managerClassLoader);
    }
  }
}

Fixed version (ground truth):
/** 
 * Releases the CacheManager with the specified URI and ClassLoader from this CachingProvider.  This does not close the CacheManager.  It simply releases it from being tracked by the CachingProvider. <p> This method does nothing if a CacheManager matching the specified parameters is not being tracked. </p>
 * @param uri         the URI of the CacheManager
 * @param classLoader the ClassLoader of the CacheManager
 */
public synchronized void releaseCacheManager(URI uri,ClassLoader classLoader){
  URI managerURI=uri == null ? getDefaultURI() : uri;
  ClassLoader managerClassLoader=classLoader == null ? getDefaultClassLoader() : classLoader;
  HashMap<URI,CacheManager> cacheManagersByURI=cacheManagersByClassLoader.get(managerClassLoader);
  if (cacheManagersByURI != null) {
    cacheManagersByURI.remove(managerURI);
    if (cacheManagersByURI.size() == 0) {
      cacheManagersByClassLoader.remove(managerClassLoader);
    }
  }
}
Program: 17221
Project: 17221
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public <T>Map<K,T> invokeAll(Set<? extends K> keys,javax.cache.processor.EntryProcessor<K,V,T> entryProcessor,Object... arguments){
  ensureOpen();
  if (keys == null) {
    throw new NullPointerException();
  }
  if (entryProcessor == null) {
    throw new NullPointerException();
  }
  HashMap<K,T> map=new HashMap<K,T>();
  for (  K key : keys) {
    T t=invoke(key,entryProcessor,arguments);
    if (t != null) {
      map.put(key,t);
    }
  }
  return map;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public <T>Map<K,EntryProcessorResult<T>> invokeAll(Set<? extends K> keys,EntryProcessor<K,V,T> entryProcessor,Object... arguments){
  ensureOpen();
  if (keys == null) {
    throw new NullPointerException();
  }
  if (entryProcessor == null) {
    throw new NullPointerException();
  }
  HashMap<K,EntryProcessorResult<T>> map=new HashMap<>();
  for (  K key : keys) {
    RIEntryProcessorResult<T> result=null;
    try {
      T t=invoke(key,entryProcessor,arguments);
      result=t == null ? null : new RIEntryProcessorResult<T>(t);
    }
 catch (    Exception e) {
      result=new RIEntryProcessorResult<T>(e);
    }
    if (result != null) {
      map.put(key,result);
    }
  }
  return map;
}
Program: 17223
Project: 17223
Buggy source:
/** 
 * Getter
 * @return the class loader
 */
protected ClassLoader getClassLoader(){
  return classLoaderReference.get();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public ClassLoader getClassLoader(){
  return classLoaderReference.get();
}
Program: 17225
Project: 17225
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public V getValue(){
  if (operation == MutableEntryOperation.NONE) {
    if (cachedValue == null || cachedValue.isExpiredAt(now)) {
      value=null;
    }
 else     if (value == null) {
      Object internalValue=cachedValue.getInternalValue(now);
      value=internalValue == null ? null : converter.fromInternal(internalValue);
    }
  }
  if (value != null) {
    if (operation == MutableEntryOperation.NONE) {
      operation=MutableEntryOperation.ACCESS;
    }
  }
 else {
    if (cacheLoader != null) {
      Cache.Entry<K,? extends V> entry=null;
      try {
        entry=cacheLoader.load(key);
        if (entry != null) {
          operation=MutableEntryOperation.CREATE;
          value=entry.getValue();
        }
      }
 catch (      Exception e) {
        if (!(e instanceof CacheLoaderException)) {
          throw new CacheLoaderException("String_Node_Str",e);
        }
 else {
          throw e;
        }
      }
    }
  }
  return value;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public V getValue(){
  if (operation == MutableEntryOperation.NONE) {
    if (cachedValue == null || cachedValue.isExpiredAt(now)) {
      value=null;
    }
 else     if (value == null) {
      Object internalValue=cachedValue.getInternalValue(now);
      value=internalValue == null ? null : converter.fromInternal(internalValue);
    }
  }
  if (value != null) {
    if (operation == MutableEntryOperation.NONE) {
      operation=MutableEntryOperation.ACCESS;
    }
  }
 else {
    if (cacheLoader != null) {
      try {
        value=cacheLoader.load(key);
        if (value != null) {
          operation=MutableEntryOperation.CREATE;
        }
      }
 catch (      Exception e) {
        if (!(e instanceof CacheLoaderException)) {
          throw new CacheLoaderException("String_Node_Str",e);
        }
 else {
          throw e;
        }
      }
    }
  }
  return value;
}
Program: 17227
Project: 17227
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public V getValue(){
  if (operation == MutableEntryOperation.NONE) {
    if (cachedValue == null || cachedValue.isExpiredAt(now)) {
      value=null;
    }
 else     if (value == null) {
      Object internalValue=cachedValue.getInternalValue(now);
      value=internalValue == null ? null : converter.fromInternal(internalValue);
    }
  }
  if (value != null) {
    if (operation == MutableEntryOperation.NONE) {
      operation=MutableEntryOperation.ACCESS;
    }
  }
 else {
    if (cacheLoader != null) {
      try {
        value=cacheLoader.load(key);
        if (value != null) {
          operation=MutableEntryOperation.CREATE;
        }
      }
 catch (      Exception e) {
        if (!(e instanceof CacheLoaderException)) {
          throw new CacheLoaderException("String_Node_Str",e);
        }
 else {
          throw e;
        }
      }
    }
  }
  return value;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public V getValue(){
  if (operation == MutableEntryOperation.NONE) {
    if (cachedValue == null || cachedValue.isExpiredAt(now)) {
      value=null;
    }
 else     if (value == null) {
      Object internalValue=cachedValue.getInternalValue(now);
      value=internalValue == null ? null : converter.fromInternal(internalValue);
    }
  }
  if (value != null) {
    if (operation == MutableEntryOperation.NONE) {
      operation=MutableEntryOperation.ACCESS;
    }
  }
 else {
    if (cacheLoader != null) {
      try {
        value=cacheLoader.load(key);
        if (value != null) {
          operation=MutableEntryOperation.LOAD;
        }
      }
 catch (      Exception e) {
        if (!(e instanceof CacheLoaderException)) {
          throw new CacheLoaderException("String_Node_Str",e);
        }
 else {
          throw e;
        }
      }
    }
  }
  return value;
}
Program: 17228
Project: 17228
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void remove(){
  operation=(operation == MutableEntryOperation.CREATE) ? MutableEntryOperation.NONE : MutableEntryOperation.REMOVE;
  value=null;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void remove(){
  operation=(operation == MutableEntryOperation.CREATE || operation == MutableEntryOperation.LOAD) ? MutableEntryOperation.NONE : MutableEntryOperation.REMOVE;
  value=null;
}
Program: 17229
Project: 17229
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public boolean replace(K key,V value){
  ensureOpen();
  if (value == null) {
    throw new NullPointerException("String_Node_Str" + key);
  }
  long now=System.currentTimeMillis();
  boolean result;
  lockManager.lock(key);
  try {
    Object internalKey=keyConverter.toInternal(key);
    RICachedValue cachedValue=entries.get(internalKey);
    if (cachedValue == null || cachedValue.isExpiredAt(now)) {
      result=false;
    }
 else {
      V oldValue=valueConverter.fromInternal(cachedValue.get());
      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=true;
    }
  }
  finally {
    lockManager.unLock(key);
  }
  if (result && statisticsEnabled()) {
    statistics.increaseCachePuts(1);
  }
  return result;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean replace(K key,V value){
  ensureOpen();
  if (value == null) {
    throw new NullPointerException("String_Node_Str" + key);
  }
  long now=System.currentTimeMillis();
  boolean result;
  lockManager.lock(key);
  try {
    Object internalKey=keyConverter.toInternal(key);
    RICachedValue cachedValue=entries.get(internalKey);
    if (cachedValue == null || cachedValue.isExpiredAt(now)) {
      result=false;
    }
 else {
      V oldValue=valueConverter.fromInternal(cachedValue.get());
      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=true;
    }
  }
  finally {
    lockManager.unLock(key);
  }
  if (result && statisticsEnabled()) {
    statistics.increaseCachePuts(1);
  }
  return result;
}
Program: 17235
Project: 17235
Buggy source:
/** 
 * Fetches the next available, non-expired entry from the underlying iterator.
 */
private void fetch(){
  while (nextEntry == null && iterator.hasNext()) {
    Map.Entry<Object,RICachedValue> entry=iterator.next();
    RICachedValue cachedValue=entry.getValue();
    K key=(K)RICache.this.keyConverter.fromInternal(entry.getKey());
    lockManager.lock(key);
    try {
      if (!cachedValue.isExpiredAt(now)) {
        V value=(V)RICache.this.valueConverter.fromInternal(cachedValue.getInternalValue(now));
        nextEntry=new RIEntry<K,V>(key,value);
        try {
          Duration duration=expiryPolicy.getExpiryForAccessedEntry(key);
          if (duration != null) {
            long expiryTime=duration.getAdjustedTime(now);
            cachedValue.setExpiryTime(expiryTime);
          }
        }
 catch (        Throwable t) {
        }
      }
    }
  finally {
      lockManager.unLock(key);
    }
  }
}

Fixed version (ground truth):
/** 
 * Fetches the next available, non-expired entry from the underlying iterator.
 */
private void fetch(){
  while (nextEntry == null && iterator.hasNext()) {
    Map.Entry<Object,RICachedValue> entry=iterator.next();
    RICachedValue cachedValue=entry.getValue();
    K key=(K)RICache.this.keyConverter.fromInternal(entry.getKey());
    lockManager.lock(key);
    try {
      if (!cachedValue.isExpiredAt(now)) {
        V value=(V)RICache.this.valueConverter.fromInternal(cachedValue.getInternalValue(now));
        nextEntry=new RIEntry<K,V>(key,value);
        try {
          Duration duration=expiryPolicy.getExpiryForAccess();
          if (duration != null) {
            long expiryTime=duration.getAdjustedTime(now);
            cachedValue.setExpiryTime(expiryTime);
          }
        }
 catch (        Throwable t) {
        }
      }
    }
  finally {
      lockManager.unLock(key);
    }
  }
}
Program: 17237
Project: 17237
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void createCache(String cacheName,Configuration configuration) throws IllegalArgumentException {
  getOrCreateInternal(cacheName,configuration,false);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public <K,V>Cache<K,V> createCache(String cacheName,Configuration<K,V> configuration) throws IllegalArgumentException {
  if (isClosed()) {
    throw new IllegalStateException();
  }
  if (cacheName == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (configuration == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if ((!configuration.isStoreByValue()) && configuration.isTransactionsEnabled()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (configuration.getTransactionIsolationLevel() == IsolationLevel.NONE && configuration.getTransactionMode() != Mode.NONE) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (configuration.getTransactionIsolationLevel() != IsolationLevel.NONE && configuration.getTransactionMode() == Mode.NONE) {
    throw new IllegalArgumentException("String_Node_Str");
  }
synchronized (caches) {
    RICache<?,?> cache=caches.get(cacheName);
    if (cache == null) {
      cache=new RICache(this,cacheName,getClassLoader(),configuration);
      caches.put(cache.getName(),cache);
      return (Cache<K,V>)cache;
    }
 else {
      throw new CacheException("String_Node_Str" + cacheName + "String_Node_Str");
    }
  }
}
Program: 17238
Project: 17238
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public <K,V>Cache<K,V> getCache(String cacheName){
  if (isClosed()) {
    throw new IllegalStateException();
  }
synchronized (caches) {
    RICache<?,?> cache=caches.get(cacheName);
    if (cache == null) {
      return null;
    }
 else {
      Configuration<?,?> configuration=cache.getConfiguration();
      if (configuration.getKeyType() == null && configuration.getValueType() == null) {
        return (Cache<K,V>)cache;
      }
 else {
        throw new IllegalArgumentException("String_Node_Str" + cacheName + "String_Node_Str"+ "String_Node_Str"+ configuration.getKeyType()+ "String_Node_Str"+ configuration.getValueType()+ "String_Node_Str"+ "String_Node_Str");
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public Cache getCache(String cacheName){
  if (isClosed()) {
    throw new IllegalStateException();
  }
synchronized (caches) {
    RICache cache=caches.get(cacheName);
    if (cache == null) {
      return null;
    }
 else {
      Configuration configuration=cache.getConfiguration();
      if (configuration.getKeyType().equals(Object.class) && configuration.getValueType().equals(Object.class)) {
        return cache;
      }
 else {
        throw new IllegalArgumentException("String_Node_Str" + cacheName + "String_Node_Str"+ "String_Node_Str"+ configuration.getKeyType()+ "String_Node_Str"+ configuration.getValueType()+ "String_Node_Str"+ "String_Node_Str");
      }
    }
  }
}
Program: 17240
Project: 17240
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void remove(){
  operation=cachedValue == null || cachedValue.isExpiredAt(now) ? MutableEntryOperation.NONE : MutableEntryOperation.REMOVE;
  value=null;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void remove(){
  operation=(operation == MutableEntryOperation.CREATE) ? MutableEntryOperation.NONE : MutableEntryOperation.REMOVE;
  value=null;
}
Program: 17241
Project: 17241
Buggy source:
/** 
 * Create a new default cache resolver that always returns the specified cache
 * @param cache The cache to return for all calls to {@link #resolveCache(CacheInvocationContext)}
 */
public DefaultCacheResolver(Cache<Object,Object> cache){
  if (cache == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.cache=cache;
}

Fixed version (ground truth):
/** 
 * Create a new default cache resolver that always returns the specified cache
 * @param cache The cache to return for all calls to {@link #resolveCache(CacheInvocationContext)}
 */
public DefaultCacheResolver(Cache<?,?> cache){
  if (cache == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.cache=cache;
}
Program: 17242
Project: 17242
Buggy source:
@Override public CacheResolver getCacheResolver(CacheMethodDetails<? extends Annotation> cacheMethodDetails){
  final String cacheName=cacheMethodDetails.getCacheName();
  Cache<Object,Object> cache=this.cacheManager.getCache(cacheName);
  if (cache == null) {
    this.logger.warning("String_Node_Str" + cacheName + "String_Node_Str");
    cache=this.cacheManager.configureCache(cacheName,new javax.cache.MutableConfiguration<Object,Object>());
  }
  return new DefaultCacheResolver(cache);
}

Fixed version (ground truth):
@Override public CacheResolver getCacheResolver(CacheMethodDetails<? extends Annotation> cacheMethodDetails){
  final String cacheName=cacheMethodDetails.getCacheName();
  Cache<?,?> cache=this.cacheManager.getCache(cacheName);
  if (cache == null) {
    this.logger.warning("String_Node_Str" + cacheName + "String_Node_Str");
    cache=this.cacheManager.configureCache(cacheName,new javax.cache.MutableConfiguration<Object,Object>());
  }
  return new DefaultCacheResolver(cache);
}
Program: 17243
Project: 17243
Buggy source:
@Override public CacheResolver getExceptionCacheResolver(CacheMethodDetails<CacheResult> cacheMethodDetails){
  final CacheResult cacheResultAnnotation=cacheMethodDetails.getCacheAnnotation();
  final String exceptionCacheName=cacheResultAnnotation.exceptionCacheName();
  if (exceptionCacheName == null || exceptionCacheName.trim().length() == 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Cache<Object,Object> cache=this.cacheManager.getCache(exceptionCacheName);
  if (cache == null) {
    this.logger.warning("String_Node_Str" + exceptionCacheName + "String_Node_Str");
    cache=this.cacheManager.configureCache(exceptionCacheName,new javax.cache.MutableConfiguration<Object,Object>());
  }
  return new DefaultCacheResolver(cache);
}

Fixed version (ground truth):
@Override public CacheResolver getExceptionCacheResolver(CacheMethodDetails<CacheResult> cacheMethodDetails){
  final CacheResult cacheResultAnnotation=cacheMethodDetails.getCacheAnnotation();
  final String exceptionCacheName=cacheResultAnnotation.exceptionCacheName();
  if (exceptionCacheName == null || exceptionCacheName.trim().length() == 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Cache<?,?> cache=this.cacheManager.getCache(exceptionCacheName);
  if (cache == null) {
    this.logger.warning("String_Node_Str" + exceptionCacheName + "String_Node_Str");
    cache=this.cacheManager.configureCache(exceptionCacheName,new javax.cache.MutableConfiguration<Object,Object>());
  }
  return new DefaultCacheResolver(cache);
}
Program: 17244
Project: 17244
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public <K,V>Cache<K,V> configureCache(String cacheName,Configuration<K,V> configuration){
  if (isClosed()) {
    throw new IllegalStateException();
  }
  if (cacheName == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (configuration == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if ((!configuration.isStoreByValue()) && configuration.isTransactionsEnabled()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (configuration.getTransactionIsolationLevel() == IsolationLevel.NONE && configuration.getTransactionMode() != Mode.NONE) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (configuration.getTransactionIsolationLevel() != IsolationLevel.NONE && configuration.getTransactionMode() == Mode.NONE) {
    throw new IllegalArgumentException("String_Node_Str");
  }
synchronized (caches) {
    Cache<?,?> cache=caches.get(cacheName);
    if (cache == null) {
      cache=new RICache<K,V>(this,cacheName,getClassLoader(),configuration);
      caches.put(cache.getName(),cache);
    }
    return (Cache<K,V>)cache;
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public <K,V>Cache<K,V> configureCache(String cacheName,Configuration<K,V> configuration){
  if (isClosed()) {
    throw new IllegalStateException();
  }
  if (cacheName == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (configuration == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if ((!configuration.isStoreByValue()) && configuration.isTransactionsEnabled()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (configuration.getTransactionIsolationLevel() == IsolationLevel.NONE && configuration.getTransactionMode() != Mode.NONE) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (configuration.getTransactionIsolationLevel() != IsolationLevel.NONE && configuration.getTransactionMode() == Mode.NONE) {
    throw new IllegalArgumentException("String_Node_Str");
  }
synchronized (caches) {
    RICache<?,?> cache=caches.get(cacheName);
    if (cache == null) {
      cache=new RICache(this,cacheName,getClassLoader(),configuration);
      caches.put(cache.getName(),cache);
    }
    return (Cache<K,V>)cache;
  }
}
Program: 17245
Project: 17245
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public <K,V>Cache<K,V> getCache(String cacheName){
  if (isClosed()) {
    throw new IllegalStateException();
  }
synchronized (caches) {
    @SuppressWarnings("String_Node_Str") final Cache<K,V> cache=(Cache<K,V>)caches.get(cacheName);
    return cache;
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public <K,V>Cache<K,V> getCache(String cacheName){
  if (isClosed()) {
    throw new IllegalStateException();
  }
synchronized (caches) {
    RICache<?,?> cache=caches.get(cacheName);
    if (cache == null) {
      return null;
    }
 else {
      Configuration<?,?> configuration=cache.getConfiguration();
      if (configuration.getKeyType() == null && configuration.getValueType() == null) {
        return (Cache<K,V>)cache;
      }
 else {
        throw new ClassCastException("String_Node_Str" + cacheName + "String_Node_Str"+ configuration.getKeyType()+ "String_Node_Str"+ configuration.getValueType()+ "String_Node_Str"+ "String_Node_Str");
      }
    }
  }
}
Program: 17246
Project: 17246
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public boolean removeCache(String cacheName){
  if (isClosed()) {
    throw new IllegalStateException();
  }
  if (cacheName == null) {
    throw new NullPointerException();
  }
  Cache<?,?> cache=getCache(cacheName);
  if (cache == null) {
    return false;
  }
 else {
    cache.close();
    return true;
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean removeCache(String cacheName){
  if (isClosed()) {
    throw new IllegalStateException();
  }
  if (cacheName == null) {
    throw new NullPointerException();
  }
  Cache<?,?> cache;
synchronized (caches) {
    cache=caches.get(cacheName);
  }
  if (cache == null) {
    return false;
  }
 else {
    cache.close();
    return true;
  }
}
Program: 17247
Project: 17247
Buggy source:
/** 
 * A copy-constructor for a   {@link RIConfiguration}.
 * @param configuration  the {@link javax.cache.Configuration} from which to copy
 */
public RIConfiguration(Configuration<K,V> configuration){
  this(configuration.getCacheEntryListenerRegistrations(),configuration.getCacheLoaderFactory(),configuration.getCacheWriterFactory(),configuration.getExpiryPolicyFactory(),configuration.isReadThrough(),configuration.isWriteThrough(),configuration.isStatisticsEnabled(),configuration.isManagementEnabled(),configuration.isStoreByValue(),configuration.isTransactionsEnabled(),configuration.getTransactionIsolationLevel(),configuration.getTransactionMode());
}

Fixed version (ground truth):
/** 
 * A copy-constructor for a   {@link RIConfiguration}.
 * @param configuration  the {@link javax.cache.Configuration} from which to copy
 */
public RIConfiguration(Configuration<K,V> configuration){
  this.keyType=configuration.getKeyType();
  this.valueType=configuration.getValueType();
  this.cacheEntryListenerRegistrations=new ArrayList<CacheEntryListenerRegistration<? super K,? super V>>();
  for (  CacheEntryListenerRegistration<? super K,? super V> r : configuration.getCacheEntryListenerRegistrations()) {
    RICacheEntryListenerRegistration<? super K,? super V> registration=new RICacheEntryListenerRegistration<K,V>(r.getCacheEntryListener(),r.getCacheEntryFilter(),r.isOldValueRequired(),r.isSynchronous());
    this.cacheEntryListenerRegistrations.add(registration);
  }
  this.cacheLoaderFactory=configuration.getCacheLoaderFactory();
  this.cacheWriterFactory=configuration.getCacheWriterFactory();
  if (configuration.getExpiryPolicyFactory() == null) {
    this.expiryPolicyFactory=ExpiryPolicy.Default.<K,V>getFactory();
  }
 else {
    this.expiryPolicyFactory=configuration.getExpiryPolicyFactory();
  }
  this.isReadThrough=configuration.isReadThrough();
  this.isWriteThrough=configuration.isWriteThrough();
  this.setStatisticsEnabled(configuration.isStatisticsEnabled());
  this.setManagementEnabled(configuration.isManagementEnabled());
  this.isStoreByValue=configuration.isStoreByValue();
  this.isTransactionsEnabled=configuration.isTransactionsEnabled();
  this.txnIsolationLevel=configuration.getTransactionIsolationLevel();
  this.txnMode=configuration.getTransactionMode();
}
Program: 17248
Project: 17248
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public int hashCode(){
  final int prime=31;
  int result=1;
  result=prime * result + ((cacheEntryListenerRegistrations == null) ? 0 : cacheEntryListenerRegistrations.hashCode());
  result=prime * result + ((cacheLoaderFactory == null) ? 0 : cacheLoaderFactory.hashCode());
  result=prime * result + ((cacheWriterFactory == null) ? 0 : cacheWriterFactory.hashCode());
  result=prime * result + ((expiryPolicyFactory == null) ? 0 : expiryPolicyFactory.hashCode());
  result=prime * result + (isReadThrough ? 1231 : 1237);
  result=prime * result + (isStatisticsEnabled() ? 1231 : 1237);
  result=prime * result + (isStoreByValue ? 1231 : 1237);
  result=prime * result + (isWriteThrough ? 1231 : 1237);
  result=prime * result + ((txnIsolationLevel == null) ? 0 : txnIsolationLevel.hashCode());
  result=prime * result + ((txnMode == null) ? 0 : txnMode.hashCode());
  return result;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public int hashCode(){
  final int prime=31;
  int result=1;
  result=prime * result + ((keyType == null) ? 0 : keyType.hashCode());
  result=prime * result + ((valueType == null) ? 0 : valueType.hashCode());
  result=prime * result + ((cacheEntryListenerRegistrations == null) ? 0 : cacheEntryListenerRegistrations.hashCode());
  result=prime * result + ((cacheLoaderFactory == null) ? 0 : cacheLoaderFactory.hashCode());
  result=prime * result + ((cacheWriterFactory == null) ? 0 : cacheWriterFactory.hashCode());
  result=prime * result + ((expiryPolicyFactory == null) ? 0 : expiryPolicyFactory.hashCode());
  result=prime * result + (isReadThrough ? 1231 : 1237);
  result=prime * result + (isStatisticsEnabled() ? 1231 : 1237);
  result=prime * result + (isStoreByValue ? 1231 : 1237);
  result=prime * result + (isWriteThrough ? 1231 : 1237);
  result=prime * result + ((txnIsolationLevel == null) ? 0 : txnIsolationLevel.hashCode());
  result=prime * result + ((txnMode == null) ? 0 : txnMode.hashCode());
  return result;
}
Program: 17252
Project: 17252
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public synchronized void close(){
  if (!isClosed) {
    isClosed=true;
    cacheManager.releaseCache(cacheName);
    setStatisticsEnabled(false);
    setManagementEnabled(false);
    executorService.shutdown();
    try {
      executorService.awaitTermination(10,TimeUnit.SECONDS);
    }
 catch (    InterruptedException e) {
      throw new CacheException(e);
    }
    entries.clear();
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public synchronized void close(){
  if (!isClosed) {
    isClosed=true;
    cacheManager.releaseCache(cacheName);
    setStatisticsEnabled(false);
    setManagementEnabled(false);
    if (cacheLoader instanceof Closeable) {
      try {
        ((Closeable)cacheLoader).close();
      }
 catch (      IOException e) {
      }
    }
    if (cacheWriter instanceof Closeable) {
      try {
        ((Closeable)cacheWriter).close();
      }
 catch (      IOException e) {
      }
    }
    if (expiryPolicy instanceof Closeable) {
      try {
        ((Closeable)expiryPolicy).close();
      }
 catch (      IOException e) {
      }
    }
    for (    RICacheEntryListenerRegistration registration : cacheEntryListenerRegistrations.values()) {
      if (registration.getCacheEntryListener() instanceof Closeable) {
        try {
          ((Closeable)registration).close();
        }
 catch (        IOException e) {
        }
      }
    }
    executorService.shutdown();
    try {
      executorService.awaitTermination(10,TimeUnit.SECONDS);
    }
 catch (    InterruptedException e) {
      throw new CacheException(e);
    }
    entries.clear();
  }
}
Program: 17253
Project: 17253
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void loadAll(final Iterable<? extends K> keys,final boolean replaceExistingValues,final CompletionListener completionListener){
  ensureOpen();
  if (keys == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (cacheLoader == null) {
    if (completionListener != null) {
      completionListener.onCompletion();
    }
  }
 else {
    for (    K key : keys) {
      if (key == null) {
        throw new NullPointerException("String_Node_Str");
      }
    }
    executorService.submit(new Runnable(){
      @Override public void run(){
        try {
          ArrayList<K> keysToLoad=new ArrayList<K>();
          for (          K key : keys) {
            if (replaceExistingValues || !containsKey(key)) {
              keysToLoad.add(key);
            }
          }
          Map<? extends K,? extends V> loaded=cacheLoader.loadAll(keysToLoad);
          for (          K key : keysToLoad) {
            if (loaded.get(key) == null) {
              loaded.remove(key);
            }
          }
          putAll(loaded,replaceExistingValues,false);
          if (completionListener != null) {
            completionListener.onCompletion();
          }
        }
 catch (        Exception e) {
          if (completionListener != null) {
            completionListener.onException(e);
          }
        }
      }
    }
);
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void loadAll(final Set<? extends K> keys,final boolean replaceExistingValues,final CompletionListener completionListener){
  ensureOpen();
  if (keys == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (cacheLoader == null) {
    if (completionListener != null) {
      completionListener.onCompletion();
    }
  }
 else {
    for (    K key : keys) {
      if (key == null) {
        throw new NullPointerException("String_Node_Str");
      }
    }
    executorService.submit(new Runnable(){
      @Override public void run(){
        try {
          ArrayList<K> keysToLoad=new ArrayList<K>();
          for (          K key : keys) {
            if (replaceExistingValues || !containsKey(key)) {
              keysToLoad.add(key);
            }
          }
          Map<? extends K,? extends V> loaded=cacheLoader.loadAll(keysToLoad);
          for (          K key : keysToLoad) {
            if (loaded.get(key) == null) {
              loaded.remove(key);
            }
          }
          putAll(loaded,replaceExistingValues,false);
          if (completionListener != null) {
            completionListener.onCompletion();
          }
        }
 catch (        Exception e) {
          if (completionListener != null) {
            completionListener.onException(e);
          }
        }
      }
    }
);
  }
}
Program: 17254
Project: 17254
Buggy source:
@Override public <T>T unwrap(java.lang.Class<T> cls){
  if (cls.isAssignableFrom(((Object)this).getClass())) {
    return cls.cast(this);
  }
  throw new IllegalArgumentException("String_Node_Str" + cls + "String_Node_Str");
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public <T>T unwrap(Class<T> clazz){
  throw new IllegalArgumentException("String_Node_Str");
}
Program: 17256
Project: 17256
Buggy source:
/** 
 * Constructs the resolver
 */
public DefaultCacheResolverFactory(){
  this.cacheManager=Caching.getCacheManager();
}

Fixed version (ground truth):
/** 
 * Constructs the resolver
 */
public DefaultCacheResolverFactory(){
  CachingProvider provider=Caching.getCachingProvider();
  this.cacheManager=provider.getCacheManager(provider.getDefaultURI(),provider.getDefaultClassLoader());
}
Program: 17257
Project: 17257
Buggy source:
/** 
 * {@inheritDoc}<p/> Statistics will also automatically be cleared if internal counters overflow.
 */
@Override public void clear(){
  cachePuts.set(0);
  cacheMisses.set(0);
  cacheRemovals.set(0);
  cacheExpiries.set(0);
  cacheHits.set(0);
  cacheEvictions.set(0);
  cacheGetTimeTakenNanos.set(0);
  cachePutTimeTakenNanos.set(0);
  cacheRemoveTimeTakenNanos.set(0);
  lastCollectionStartDate=new Date();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}<p/> Statistics will also automatically be cleared if internal counters overflow.
 */
@Override public void clear(){
  cachePuts.set(0);
  cacheMisses.set(0);
  cacheRemovals.set(0);
  cacheExpiries.set(0);
  cacheHits.set(0);
  cacheEvictions.set(0);
  cacheGetTimeTakenNanos.set(0);
  cachePutTimeTakenNanos.set(0);
  cacheRemoveTimeTakenNanos.set(0);
}
Program: 17258
Project: 17258
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public <K,V>Cache<K,V> configureCache(String cacheName,Configuration<K,V> configuration){
  if (isClosed()) {
    throw new IllegalStateException();
  }
  if (cacheName == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (configuration == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (configuration.getTransactionIsolationLevel() == IsolationLevel.NONE && configuration.getTransactionMode() != Mode.NONE) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (configuration.getTransactionIsolationLevel() != IsolationLevel.NONE && configuration.getTransactionMode() == Mode.NONE) {
    throw new IllegalArgumentException("String_Node_Str");
  }
synchronized (caches) {
    Cache<?,?> cache=caches.get(cacheName);
    if (cache == null) {
      cache=new RICache<K,V>(this,cacheName,getClassLoader(),configuration);
      caches.put(cache.getName(),cache);
    }
 else {
      RIConfiguration<K,V> config=new RIConfiguration<K,V>(configuration);
      if (!cache.getConfiguration().equals(config)) {
        throw new CacheException("String_Node_Str" + cache.getName() + "String_Node_Str");
      }
    }
    return (Cache<K,V>)cache;
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public <K,V>Cache<K,V> configureCache(String cacheName,Configuration<K,V> configuration){
  if (isClosed()) {
    throw new IllegalStateException();
  }
  if (cacheName == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (configuration == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if ((!configuration.isStoreByValue()) && configuration.isTransactionsEnabled()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (configuration.getTransactionIsolationLevel() == IsolationLevel.NONE && configuration.getTransactionMode() != Mode.NONE) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (configuration.getTransactionIsolationLevel() != IsolationLevel.NONE && configuration.getTransactionMode() == Mode.NONE) {
    throw new IllegalArgumentException("String_Node_Str");
  }
synchronized (caches) {
    Cache<?,?> cache=caches.get(cacheName);
    if (cache == null) {
      cache=new RICache<K,V>(this,cacheName,getClassLoader(),configuration);
      caches.put(cache.getName(),cache);
    }
 else {
      RIConfiguration<K,V> config=new RIConfiguration<K,V>(configuration);
      if (!cache.getConfiguration().equals(config)) {
        throw new CacheException("String_Node_Str" + cache.getName() + "String_Node_Str");
      }
    }
    return (Cache<K,V>)cache;
  }
}
Program: 17259
Project: 17259
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public boolean replace(K key,V value){
  checkStatusStarted();
  if (value == null) {
    throw new NullPointerException("String_Node_Str" + key);
  }
  long now=System.currentTimeMillis();
  boolean result;
  lockManager.lock(key);
  try {
    Object internalKey=keyConverter.toInternal(key);
    RICachedValue cachedValue=entries.get(internalKey);
    if (cachedValue == null || cachedValue.isExpiredAt(now)) {
      result=false;
    }
 else {
      RIEntry<K,V> entry=new RIEntry<K,V>(key,value);
      writeCacheEntry(entry);
      V previousValue=valueConverter.fromInternal(cachedValue.get());
      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,previousValue));
      dispatcher.dispatch(cacheEntryListenerRegistrations.values());
      result=true;
    }
  }
  finally {
    lockManager.unLock(key);
  }
  if (result && statisticsEnabled()) {
    statistics.increaseCachePuts(1);
  }
  return result;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean replace(K key,V value){
  checkStatusStarted();
  if (value == null) {
    throw new NullPointerException("String_Node_Str" + key);
  }
  long now=System.currentTimeMillis();
  boolean result;
  lockManager.lock(key);
  try {
    Object internalKey=keyConverter.toInternal(key);
    RICachedValue cachedValue=entries.get(internalKey);
    if (cachedValue == null || cachedValue.isExpiredAt(now)) {
      result=false;
    }
 else {
      RIEntry<K,V> entry=new RIEntry<K,V>(key,value);
      writeCacheEntry(entry);
      V previousValue=valueConverter.fromInternal(cachedValue.get());
      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,previousValue));
      dispatcher.dispatch(cacheEntryListenerRegistrations.values());
      result=true;
    }
  }
  finally {
    lockManager.unLock(key);
  }
  if (result && statisticsEnabled()) {
    statistics.increaseCachePuts(1);
  }
  return result;
}
Program: 17265
Project: 17265
Buggy source:
/** 
 * Fetches the next available, non-expired entry from the underlying  iterator.
 */
private void fetch(){
  while (nextEntry == null && iterator.hasNext()) {
    Map.Entry<Object,RICachedValue> entry=iterator.next();
    RICachedValue cachedValue=entry.getValue();
    K key=(K)RICache.this.keyConverter.fromInternal(entry.getKey());
    lockManager.lock(key);
    try {
      if (!cachedValue.isExpiredAt(now)) {
        V value=(V)RICache.this.valueConverter.fromInternal(cachedValue.getInternalValue(now));
        nextEntry=new RIEntry<K,V>(key,value);
        Duration duration=expiryPolicy.getTTLForAccessedEntry(nextEntry,new Duration(now,cachedValue.getExpiryTime()));
        long expiryTime=duration.getAdjustedTime(now);
        cachedValue.setExpiryTime(expiryTime);
      }
    }
  finally {
      lockManager.unLock(key);
    }
  }
}

Fixed version (ground truth):
/** 
 * Fetches the next available, non-expired entry from the underlying  iterator.
 */
private void fetch(){
  while (nextEntry == null && iterator.hasNext()) {
    Map.Entry<Object,RICachedValue> entry=iterator.next();
    RICachedValue cachedValue=entry.getValue();
    K key=(K)RICache.this.keyConverter.fromInternal(entry.getKey());
    lockManager.lock(key);
    try {
      if (!cachedValue.isExpiredAt(now)) {
        V value=(V)RICache.this.valueConverter.fromInternal(cachedValue.getInternalValue(now));
        nextEntry=new RIEntry<K,V>(key,value);
        Duration duration;
        try {
          duration=expiryPolicy.getTTLForAccessedEntry(nextEntry,new Duration(now,cachedValue.getExpiryTime()));
        }
 catch (        Throwable t) {
          duration=getDefaultDuration();
        }
        long expiryTime=duration.getAdjustedTime(now);
        cachedValue.setExpiryTime(expiryTime);
      }
    }
  finally {
      lockManager.unLock(key);
    }
  }
}
Program: 17267
Project: 17267
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(CacheEntryReadListener.class,new RICacheEntryEvent<K,V>(this,key,result));
      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=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;
}
Program: 17268
Project: 17268
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public V getAndRemove(K key){
  checkStatusStarted();
  long now=System.currentTimeMillis();
  V result;
  lockManager.lock(key);
  try {
    deleteCacheEntry(key);
    Object internalKey=keyConverter.toInternal(key);
    RICachedValue cachedValue=entries.get(internalKey);
    if (cachedValue == null || cachedValue.isExpiredAt(now)) {
      result=null;
    }
 else {
      entries.remove(internalKey);
      result=valueConverter.fromInternal(cachedValue.getInternalValue(now));
      CacheEntryEvent<K,V> event=new RICacheEntryEvent<K,V>(this,key,result);
      RICacheEventEventDispatcher<K,V> dispatcher=new RICacheEventEventDispatcher<K,V>();
      dispatcher.addEvent(CacheEntryReadListener.class,event);
      dispatcher.addEvent(CacheEntryRemovedListener.class,event);
      dispatcher.dispatch(cacheEntryListenerRegistrations.values());
    }
  }
  finally {
    lockManager.unLock(key);
  }
  if (statisticsEnabled()) {
    if (result != null) {
      statistics.increaseCacheHits(1);
      statistics.increaseCacheRemovals(1);
    }
 else {
      statistics.increaseCacheMisses(1);
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public V getAndRemove(K key){
  checkStatusStarted();
  long now=System.currentTimeMillis();
  V result;
  lockManager.lock(key);
  try {
    deleteCacheEntry(key);
    Object internalKey=keyConverter.toInternal(key);
    RICachedValue cachedValue=entries.get(internalKey);
    if (cachedValue == null || cachedValue.isExpiredAt(now)) {
      result=null;
    }
 else {
      entries.remove(internalKey);
      result=valueConverter.fromInternal(cachedValue.getInternalValue(now));
      CacheEntryEvent<K,V> event=new RICacheEntryEvent<K,V>(this,key,result);
      RICacheEventEventDispatcher<K,V> dispatcher=new RICacheEventEventDispatcher<K,V>();
      dispatcher.addEvent(CacheEntryRemovedListener.class,event);
      dispatcher.dispatch(cacheEntryListenerRegistrations.values());
    }
  }
  finally {
    lockManager.unLock(key);
  }
  if (statisticsEnabled()) {
    if (result != null) {
      statistics.increaseCacheHits(1);
      statistics.increaseCacheRemovals(1);
    }
 else {
      statistics.increaseCacheMisses(1);
    }
  }
  return result;
}
Program: 17269
Project: 17269
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public Entry<K,V> next(){
  if (hasNext()) {
    lastEntry=nextEntry;
    RICacheEventEventDispatcher<K,V> dispatcher=new RICacheEventEventDispatcher<K,V>();
    dispatcher.addEvent(CacheEntryReadListener.class,new RICacheEntryEvent<K,V>(RICache.this,lastEntry.getKey(),lastEntry.getValue()));
    dispatcher.dispatch(cacheEntryListenerRegistrations.values());
    nextEntry=null;
    return lastEntry;
  }
 else {
    throw new NoSuchElementException();
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public Entry<K,V> next(){
  if (hasNext()) {
    lastEntry=nextEntry;
    nextEntry=null;
    return lastEntry;
  }
 else {
    throw new NoSuchElementException();
  }
}