Program: 16243
Project: 16243
Buggy source:
/** 
 * This method tries to parse maximum <code>max</code> records from the open File or InputStream, and leaves the underlying resource open.<br> Subsequent calls to the same method continue parsing the rest of the file.<br> This is particularly useful when dealing with very big data files, (e.g. NCBI nr database), which can't fit into memory and will take long time before the first result is available.<br> <b>N.B.</b> <ul> <li>This method can't be called after calling its NO-ARGUMENT twin.</li> <li>remember to close the underlying resource when you are done.</li> </ul>
 * @see #process()
 * @author Amr AL-Hossary
 * @since 3.0.6
 * @param max maximum number of records to return, <code>-1</code> for infinity.
 * @return {@link HashMap} containing maximum <code>max</code> parsed fasta recordspresent, starting current fileIndex onwards.
 * @throws IOException if an error occurs reading the input file
 */
public LinkedHashMap<String,S> process(int max) throws IOException {
  String line="String_Node_Str";
  if (this.line != null && this.line.length() > 0) {
    line=this.line;
  }
  String header="String_Node_Str";
  if (this.header != null && this.header.length() > 0) {
    header=this.header;
  }
  StringBuilder sb=new StringBuilder();
  int processedSequences=0;
  boolean keepGoing=true;
  LinkedHashMap<String,S> sequences=new LinkedHashMap<String,S>();
  do {
    line=line.trim();
    if (line.length() != 0) {
      if (line.startsWith("String_Node_Str")) {
        if (sb.length() > 0) {
          try {
            @SuppressWarnings("String_Node_Str") S sequence=(S)sequenceCreator.getSequence(sb.toString(),sequenceIndex);
            headerParser.parseHeader(header,sequence);
            sequences.put(sequence.getAccession().getID(),sequence);
            processedSequences++;
          }
 catch (          CompoundNotFoundException e) {
            logger.warn("String_Node_Str",header,e.getMessage());
          }
          sb.setLength(0);
        }
        header=line.substring(1);
      }
 else       if (line.startsWith("String_Node_Str")) {
      }
 else {
        if (sb.length() == 0) {
          sequenceIndex=fileIndex;
        }
        sb.append(line);
      }
    }
    fileIndex=br.getBytesRead();
    line=br.readLine();
    if (line == null) {
      if (sequences.size() == 0 && max != -1) {
        return null;
      }
      String seq=sb.toString();
      if (seq.length() == 0) {
        logger.warn("String_Node_Str",sequenceIndex);
        logger.warn("String_Node_Str",header);
      }
      try {
        @SuppressWarnings("String_Node_Str") S sequence=(S)sequenceCreator.getSequence(seq,sequenceIndex);
        headerParser.parseHeader(header,sequence);
        sequences.put(sequence.getAccession().getID(),sequence);
        processedSequences++;
      }
 catch (      CompoundNotFoundException e) {
        logger.warn("String_Node_Str",header,e.getMessage());
      }
      keepGoing=false;
    }
    if (max > -1 && processedSequences >= max) {
      keepGoing=false;
    }
    if (this.line == null)     keepGoing=false;
  }
 while (keepGoing);
  this.line=line;
  this.header=header;
  return sequences;
}

Fixed version (ground truth):
/** 
 * This method tries to parse maximum <code>max</code> records from the open File or InputStream, and leaves the underlying resource open.<br> Subsequent calls to the same method continue parsing the rest of the file.<br> This is particularly useful when dealing with very big data files, (e.g. NCBI nr database), which can't fit into memory and will take long time before the first result is available.<br> <b>N.B.</b> <ul> <li>This method can't be called after calling its NO-ARGUMENT twin.</li> <li>remember to close the underlying resource when you are done.</li> <li>This method always return non-null hash map. When end-of-file is reached, the number of sequences returned will be smaller than the number requested.</li> </ul>
 * @see #process()
 * @author Amr AL-Hossary
 * @since 3.0.6
 * @param max maximum number of records to return, <code>-1</code> for infinity.
 * @return {@link HashMap} containing maximum <code>max</code> parsed fasta recordspresent, starting current fileIndex onwards.
 * @throws IOException if an error occurs reading the input file
 */
public LinkedHashMap<String,S> process(int max) throws IOException {
  String line="String_Node_Str";
  if (this.line != null && this.line.length() > 0) {
    line=this.line;
  }
  String header="String_Node_Str";
  if (this.header != null && this.header.length() > 0) {
    header=this.header;
  }
  StringBuilder sb=new StringBuilder();
  int processedSequences=0;
  boolean keepGoing=true;
  LinkedHashMap<String,S> sequences=new LinkedHashMap<String,S>();
  do {
    line=line.trim();
    if (line.length() != 0) {
      if (line.startsWith("String_Node_Str")) {
        if (sb.length() > 0) {
          try {
            @SuppressWarnings("String_Node_Str") S sequence=(S)sequenceCreator.getSequence(sb.toString(),sequenceIndex);
            headerParser.parseHeader(header,sequence);
            sequences.put(sequence.getAccession().getID(),sequence);
            processedSequences++;
          }
 catch (          CompoundNotFoundException e) {
            logger.warn("String_Node_Str",header,e.getMessage());
          }
          sb.setLength(0);
        }
        header=line.substring(1);
      }
 else       if (line.startsWith("String_Node_Str")) {
      }
 else {
        if (sb.length() == 0) {
          sequenceIndex=fileIndex;
        }
        sb.append(line);
      }
    }
    fileIndex=br.getBytesRead();
    line=br.readLine();
    if (line == null) {
      if (sb.length() == 0 && header.length() != 0) {
        logger.warn("String_Node_Str",sequenceIndex);
        logger.warn("String_Node_Str",header);
        header=null;
      }
 else       if (sb.length() > 0) {
        try {
          @SuppressWarnings("String_Node_Str") S sequence=(S)sequenceCreator.getSequence(sb.toString(),sequenceIndex);
          headerParser.parseHeader(header,sequence);
          sequences.put(sequence.getAccession().getID(),sequence);
          processedSequences++;
          header=null;
        }
 catch (        CompoundNotFoundException e) {
          logger.warn("String_Node_Str",header,e.getMessage());
        }
      }
      keepGoing=false;
    }
    if (max > -1 && processedSequences >= max) {
      keepGoing=false;
    }
  }
 while (keepGoing);
  this.line=line;
  this.header=header;
  return sequences;
}