Program: 82197
Project: 82197
Buggy source:
/** 
 * NOTE: This is a potentially dangerous call, it will return all the documents that match the term.
 * @param selector
 * @param primeDocTerm
 * @param filter
 * @param totalRecords
 * @param highlighter
 * @throws IOException
 */
@SuppressWarnings("String_Node_Str") public static List<Document> fetchDocuments(IndexReader reader,ResetableDocumentStoredFieldVisitor fieldSelector,Selector selector,int maxHeap,String context,Term primeDocTerm,Filter filter,AtomicBoolean moreToFetch,AtomicInteger totalRecords,BlurHighlighter highlighter) throws IOException {
  if (highlighter == null) {
    highlighter=new BlurHighlighter();
  }
  if (reader instanceof BaseCompositeReader) {
    BaseCompositeReader<IndexReader> indexReader=(BaseCompositeReader<IndexReader>)reader;
    List<? extends IndexReader> sequentialSubReaders=BaseCompositeReaderUtil.getSequentialSubReaders(indexReader);
    String locationId=selector.getLocationId();
    int indexOf=locationId.indexOf('/');
    if (indexOf < 0) {
      throw new IOException("String_Node_Str" + locationId + "String_Node_Str");
    }
    int notAdjustedPrimeDocId=Integer.parseInt(locationId.substring(indexOf + 1));
    int readerIndex=BaseCompositeReaderUtil.readerIndex(indexReader,notAdjustedPrimeDocId);
    int readerBase=BaseCompositeReaderUtil.readerBase(indexReader,readerIndex);
    int primeDocId=notAdjustedPrimeDocId - readerBase;
    IndexReader orgReader=sequentialSubReaders.get(readerIndex);
    SegmentReader sReader=AtomicReaderUtil.getSegmentReader(orgReader);
    if (sReader != null) {
      SegmentReader segmentReader=(SegmentReader)sReader;
      Bits liveDocs=segmentReader.getLiveDocs();
      OpenBitSet bitSet=PrimeDocCache.getPrimeDocBitSet(primeDocTerm,segmentReader);
      int nextPrimeDoc=bitSet.nextSetBit(primeDocId + 1);
      int numberOfDocsInRow;
      if (nextPrimeDoc == -1) {
        numberOfDocsInRow=segmentReader.maxDoc() - primeDocId;
      }
 else {
        numberOfDocsInRow=nextPrimeDoc - primeDocId;
      }
      OpenBitSet docsInRowSpanToFetch=getDocsToFetch(segmentReader,selector,primeDocId,numberOfDocsInRow,liveDocs,filter,totalRecords);
      int start=selector.getStartRecord();
      int maxDocsToFetch=selector.getMaxRecordsToFetch();
      int startingPosition=getStartingPosition(docsInRowSpanToFetch,start);
      List<Document> docs=new ArrayList<Document>();
      if (startingPosition < 0) {
        return docs;
      }
      int totalHeap=0;
      Tracer trace2=Trace.trace("String_Node_Str");
      int cursor=0;
      try {
        for (cursor=startingPosition; cursor < numberOfDocsInRow; cursor++) {
          if (maxDocsToFetch <= 0) {
            return docs;
          }
          if (totalHeap >= maxHeap) {
            LOG.warn("String_Node_Str",totalHeap,maxHeap,context,selector);
            return docs;
          }
          if (docsInRowSpanToFetch.fastGet(cursor)) {
            maxDocsToFetch--;
            int docID=primeDocId + cursor;
            segmentReader.document(docID,fieldSelector);
            Document document=fieldSelector.getDocument();
            if (highlighter.shouldHighlight()) {
              docs.add(highlighter.highlight(docID,document,segmentReader));
            }
 else {
              docs.add(document);
            }
            totalHeap+=fieldSelector.getSize();
            fieldSelector.reset();
          }
        }
      }
  finally {
        if (docsInRowSpanToFetch.nextSetBit(cursor) != -1) {
          moreToFetch.set(true);
        }
        trace2.done();
      }
      return orderDocsBasedOnFamilyOrder(docs,selector);
    }
 else {
      throw new IOException("String_Node_Str" + orgReader + "String_Node_Str");
    }
  }
  throw new IOException("String_Node_Str" + reader + "String_Node_Str");
}

Fixed version (ground truth):
/** 
 * NOTE: This is a potentially dangerous call, it will return all the documents that match the term.
 * @param selector
 * @param primeDocTerm
 * @param filter
 * @param totalRecords
 * @param highlighter
 * @throws IOException
 */
@SuppressWarnings("String_Node_Str") public static List<Document> fetchDocuments(IndexReader reader,ResetableDocumentStoredFieldVisitor fieldSelector,Selector selector,int maxHeap,String context,Term primeDocTerm,Filter filter,AtomicBoolean moreToFetch,AtomicInteger totalRecords,BlurHighlighter highlighter) throws IOException {
  if (highlighter == null) {
    highlighter=new BlurHighlighter();
  }
  if (reader instanceof BaseCompositeReader) {
    BaseCompositeReader<IndexReader> indexReader=(BaseCompositeReader<IndexReader>)reader;
    List<? extends IndexReader> sequentialSubReaders=BaseCompositeReaderUtil.getSequentialSubReaders(indexReader);
    String locationId=selector.getLocationId();
    int indexOf=locationId.indexOf('/');
    if (indexOf < 0) {
      throw new IOException("String_Node_Str" + locationId + "String_Node_Str");
    }
    int notAdjustedPrimeDocId=Integer.parseInt(locationId.substring(indexOf + 1));
    int readerIndex=BaseCompositeReaderUtil.readerIndex(indexReader,notAdjustedPrimeDocId);
    int readerBase=BaseCompositeReaderUtil.readerBase(indexReader,readerIndex);
    int primeDocId=notAdjustedPrimeDocId - readerBase;
    IndexReader orgReader=sequentialSubReaders.get(readerIndex);
    if (orgReader != null && orgReader instanceof AtomicReader) {
      AtomicReader atomicReader=(AtomicReader)orgReader;
      Bits liveDocs=atomicReader.getLiveDocs();
      OpenBitSet bitSet=PrimeDocCache.getPrimeDocBitSet(primeDocTerm,atomicReader);
      int nextPrimeDoc=bitSet.nextSetBit(primeDocId + 1);
      int numberOfDocsInRow;
      if (nextPrimeDoc == -1) {
        numberOfDocsInRow=atomicReader.maxDoc() - primeDocId;
      }
 else {
        numberOfDocsInRow=nextPrimeDoc - primeDocId;
      }
      OpenBitSet docsInRowSpanToFetch=getDocsToFetch(atomicReader,selector,primeDocId,numberOfDocsInRow,liveDocs,filter,totalRecords);
      int start=selector.getStartRecord();
      int maxDocsToFetch=selector.getMaxRecordsToFetch();
      int startingPosition=getStartingPosition(docsInRowSpanToFetch,start);
      List<Document> docs=new ArrayList<Document>();
      if (startingPosition < 0) {
        return docs;
      }
      int totalHeap=0;
      Tracer trace2=Trace.trace("String_Node_Str");
      int cursor=0;
      try {
        for (cursor=startingPosition; cursor < numberOfDocsInRow; cursor++) {
          if (maxDocsToFetch <= 0) {
            return docs;
          }
          if (totalHeap >= maxHeap) {
            LOG.warn("String_Node_Str",totalHeap,maxHeap,context,selector);
            return docs;
          }
          if (docsInRowSpanToFetch.fastGet(cursor)) {
            maxDocsToFetch--;
            int docID=primeDocId + cursor;
            atomicReader.document(docID,fieldSelector);
            Document document=fieldSelector.getDocument();
            if (highlighter.shouldHighlight()) {
              docs.add(highlighter.highlight(docID,document,atomicReader));
            }
 else {
              docs.add(document);
            }
            totalHeap+=fieldSelector.getSize();
            fieldSelector.reset();
          }
        }
      }
  finally {
        if (docsInRowSpanToFetch.nextSetBit(cursor) != -1) {
          moreToFetch.set(true);
        }
        trace2.done();
      }
      return orderDocsBasedOnFamilyOrder(docs,selector);
    }
 else {
      throw new IOException("String_Node_Str" + orgReader + "String_Node_Str");
    }
  }
  throw new IOException("String_Node_Str" + reader + "String_Node_Str");
}