Program: 32810
Project: 32810
Buggy source:
/** 
 * Fetches a particular element. <p>This might seem redundant with the existence of   {@link #get(int)}. However, the goals of the methods are different.  This method exists to be called by   {@link #get(int)} or {@link #preFetch(int)}. This distinction allows users overriding this class a means of entry retrieval which does not implicitly execute a pre-fetch.  This is particularly key for users overriding   {@link #preFetch(int)}
 * @param index The index of the value to retrieve
 * @param recordHitsOrMisses Whether to increment the hit/miss counters(this should always be <code>false</code> when called from {@link #preFetch(int)}).
 * @return The value associated with the given index,or null if the index is not found.
 */
protected final Object fetch(int index,boolean recordHitsOrMisses){
  getReadWriteLock().writeLock().lock();
  try {
    Object value=null;
    IndexedTreeNode indexNode=indexTree.getNode(index);
    Object nodeValue=indexNode.getValue();
    if (EMPTY_INDEX_NODE != nodeValue && nodeValue != null) {
      if (recordHitsOrMisses)       cacheHits++;
      IndexedTreeNode cacheNode=(IndexedTreeNode)indexNode.getValue();
      AgedNode agedNode=(AgedNode)cacheNode.getValue();
      value=agedNode.getValue();
      cacheNode.removeFromTree();
      indexNode.setValue(cache.addByNode(agedNode));
    }
 else {
      if (recordHitsOrMisses)       cacheMisses++;
      value=source.get(index);
      if (currentSize < maxSize) {
        currentSize++;
        IndexedTreeNode cacheNode=cache.addByNode(new AgedNode(indexNode,value));
        indexNode.setValue(cacheNode);
      }
 else {
        IndexedTreeNode oldestInCache=cache.getNode(0);
        oldestInCache.removeFromTree();
        AgedNode oldAgedNode=(AgedNode)oldestInCache.getValue();
        IndexedTreeNode oldIndexNode=oldAgedNode.getIndexNode();
        oldIndexNode.setValue(EMPTY_INDEX_NODE);
        IndexedTreeNode cacheNode=cache.addByNode(new AgedNode(indexNode,value));
        indexNode.setValue(cacheNode);
      }
    }
    return value;
  }
  finally {
    getReadWriteLock().writeLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * Fetches a particular element. <p>This might seem redundant with the existence of   {@link #get(int)}. However, the goals of the methods are different.  This method exists to be called by   {@link #get(int)} or {@link #preFetch(int)}. This distinction allows users overriding this class a means of entry retrieval which does not implicitly execute a pre-fetch.  This is particularly key for users overriding   {@link #preFetch(int)}
 * @param index The index of the value to retrieve
 * @param recordHitsOrMisses Whether to increment the hit/miss counters(this should always be <code>false</code> when called from {@link #preFetch(int)}).
 * @return The value associated with the given index,or null if the index is not found.
 */
protected final Object fetch(int index,boolean recordHitsOrMisses){
  Object value=null;
  IndexedTreeNode indexNode=indexTree.getNode(index);
  Object nodeValue=indexNode.getValue();
  if (EMPTY_INDEX_NODE != nodeValue && nodeValue != null) {
    if (recordHitsOrMisses)     cacheHits++;
    IndexedTreeNode cacheNode=(IndexedTreeNode)indexNode.getValue();
    AgedNode agedNode=(AgedNode)cacheNode.getValue();
    value=agedNode.getValue();
    cacheNode.removeFromTree();
    indexNode.setValue(cache.addByNode(agedNode));
  }
 else {
    if (recordHitsOrMisses)     cacheMisses++;
    value=source.get(index);
    if (currentSize < maxSize) {
      currentSize++;
      IndexedTreeNode cacheNode=cache.addByNode(new AgedNode(indexNode,value));
      indexNode.setValue(cacheNode);
    }
 else {
      IndexedTreeNode oldestInCache=cache.getNode(0);
      oldestInCache.removeFromTree();
      AgedNode oldAgedNode=(AgedNode)oldestInCache.getValue();
      IndexedTreeNode oldIndexNode=oldAgedNode.getIndexNode();
      oldIndexNode.setValue(EMPTY_INDEX_NODE);
      IndexedTreeNode cacheNode=cache.addByNode(new AgedNode(indexNode,value));
      indexNode.setValue(cacheNode);
    }
  }
  return value;
}