Program: 17013
Project: 17013
Buggy source:
/** 
 * Parses a Stockholm file and returns a   {@link StockholmStructure} object with its content.This method returns just after reaching the end of structure delimiter line ("//"), leaving any remaining empty lines unconsumed.
 * @param scanner from where to read the file content
 * @return Stockholm file content
 * @throws IOException 
 * @throws Exception
 */
StockholmStructure parse(Scanner scanner) throws ParserException, IOException {
  if (scanner == null) {
    if (internalScanner != null) {
      scanner=internalScanner;
    }
 else {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
  this.stockholmStructure=new StockholmStructure();
  String line=null;
  int linesCount=0;
  try {
    do {
      line=scanner.nextLine();
      if (linesCount == 0 && line == null) {
        throw new IOException("String_Node_Str");
      }
      if ((line == null) || line.trim().length() == 0) {
        continue;
      }
      if (line.startsWith("String_Node_Str")) {
        if (line.startsWith(GENERIC_PER_FILE_ANNOTATION,2)) {
          int firstSpaceIndex=line.indexOf(' ',5);
          String featureName=line.substring(5,firstSpaceIndex);
          String value=line.substring(firstSpaceIndex).trim();
          handleFileAnnotation(featureName,value);
        }
 else         if (line.startsWith(GENERIC_PER_CONSENSUS_ANNOTATION,2)) {
          this.status=STATUS_INSIDE_FILE;
          int firstSpaceIndex=line.indexOf(' ',5);
          String featureName=line.substring(5,firstSpaceIndex);
          String value=line.substring(firstSpaceIndex).trim();
          handleConsensusAnnotation(featureName,value);
        }
 else         if (line.startsWith(GENERIC_PER_SEQUENCE_ANNOTATION,2)) {
          int index1=line.indexOf(' ',5);
          String seqName=line.substring(5,index1);
          while (line.charAt(++index1) <= ' ')           ;
          int index2=line.indexOf(' ',index1);
          String featureName=line.substring(index1,index2);
          String value=line.substring(index2).trim();
          handleSequenceAnnotation(seqName,featureName,value);
        }
 else         if (line.startsWith(GENERIC_PER_RESIDUE_ANNOTATION,2)) {
          int index1=line.indexOf(' ',5);
          String seqName=line.substring(5,index1);
          while (line.charAt(++index1) == ' ')           ;
          int index2=line.indexOf(' ',index1);
          String featureName=line.substring(index1,index2);
          String value=line.substring(index2).trim();
          handleResidueAnnotation(seqName,featureName,value);
        }
      }
 else       if (line.startsWith("String_Node_Str")) {
        if (status == STATUS_OUTSIDE_FILE) {
          status=STATUS_INSIDE_FILE;
          String[] header=line.split("String_Node_Str");
          stockholmStructure.getFileAnnotation().setFormat(header[1]);
          stockholmStructure.getFileAnnotation().setVersion(header[2]);
        }
 else {
          throw new ParserException("String_Node_Str" + line + "String_Node_Str");
        }
      }
 else       if (line.trim().equals("String_Node_Str")) {
        status=STATUS_OUTSIDE_FILE;
        break;
      }
 else {
        if (status == STATUS_IN_SEQUENCE) {
          handleSequenceLine(line);
        }
 else {
          System.err.println("String_Node_Str" + line + "String_Node_Str");
          throw new ParserException("String_Node_Str" + line + "String_Node_Str");
        }
      }
      linesCount++;
    }
 while (scanner.hasNextLine());
  }
 catch (  IOException e) {
    e.printStackTrace();
    throw new IOException("String_Node_Str");
  }
  int length=-1;
  Map<String,StringBuffer> sequences=stockholmStructure.getSequences();
  for (  String sequencename : sequences.keySet()) {
    StringBuffer sequence=sequences.get(sequencename);
    if (length == -1) {
      length=sequence.length();
    }
 else     if (length != sequence.length()) {
      throw new RuntimeException("String_Node_Str");
    }
  }
  return this.stockholmStructure;
}

Fixed version (ground truth):
/** 
 * Parses a Stockholm file and returns a   {@link StockholmStructure} object with its content.This method returns just after reaching the end of structure delimiter line ("//"), leaving any remaining empty lines unconsumed.
 * @param scanner from where to read the file content
 * @return Stockholm file content, <code>null</code> if couldn't or no more structures.
 * @throws IOException 
 * @throws Exception
 */
StockholmStructure parse(Scanner scanner) throws ParserException, IOException {
  if (scanner == null) {
    if (internalScanner != null) {
      scanner=internalScanner;
    }
 else {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
  String line=null;
  int linesCount=0;
  try {
    while (scanner.hasNextLine()) {
      line=scanner.nextLine();
      if (linesCount == 0 && line == null) {
        throw new IOException("String_Node_Str");
      }
      if ((line == null) || line.trim().length() == 0) {
        continue;
      }
      if (line.startsWith("String_Node_Str")) {
        if (line.startsWith(GENERIC_PER_FILE_ANNOTATION,2)) {
          int firstSpaceIndex=line.indexOf(' ',5);
          String featureName=line.substring(5,firstSpaceIndex);
          String value=line.substring(firstSpaceIndex).trim();
          handleFileAnnotation(featureName,value);
        }
 else         if (line.startsWith(GENERIC_PER_CONSENSUS_ANNOTATION,2)) {
          this.status=STATUS_INSIDE_FILE;
          int firstSpaceIndex=line.indexOf(' ',5);
          String featureName=line.substring(5,firstSpaceIndex);
          String value=line.substring(firstSpaceIndex).trim();
          handleConsensusAnnotation(featureName,value);
        }
 else         if (line.startsWith(GENERIC_PER_SEQUENCE_ANNOTATION,2)) {
          int index1=line.indexOf(' ',5);
          String seqName=line.substring(5,index1);
          while (line.charAt(++index1) <= ' ')           ;
          int index2=line.indexOf(' ',index1);
          String featureName=line.substring(index1,index2);
          String value=line.substring(index2).trim();
          handleSequenceAnnotation(seqName,featureName,value);
        }
 else         if (line.startsWith(GENERIC_PER_RESIDUE_ANNOTATION,2)) {
          int index1=line.indexOf(' ',5);
          String seqName=line.substring(5,index1);
          while (line.charAt(++index1) == ' ')           ;
          int index2=line.indexOf(' ',index1);
          String featureName=line.substring(index1,index2);
          String value=line.substring(index2).trim();
          handleResidueAnnotation(seqName,featureName,value);
        }
      }
 else       if (line.startsWith("String_Node_Str")) {
        if (status == STATUS_OUTSIDE_FILE) {
          status=STATUS_INSIDE_FILE;
          String[] header=line.split("String_Node_Str");
          this.stockholmStructure=new StockholmStructure();
          this.stockholmStructure.getFileAnnotation().setFormat(header[1]);
          this.stockholmStructure.getFileAnnotation().setVersion(header[2]);
        }
 else {
          throw new ParserException("String_Node_Str" + line + "String_Node_Str");
        }
      }
 else       if (line.trim().equals("String_Node_Str")) {
        status=STATUS_OUTSIDE_FILE;
        break;
      }
 else {
        if (status == STATUS_IN_SEQUENCE) {
          handleSequenceLine(line);
        }
 else {
          System.err.println("String_Node_Str" + line + "String_Node_Str");
          throw new ParserException("String_Node_Str" + line + "String_Node_Str");
        }
      }
      linesCount++;
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
    throw new IOException("String_Node_Str");
  }
  StockholmStructure structure=this.stockholmStructure;
  this.stockholmStructure=null;
  if (structure != null) {
    int length=-1;
    Map<String,StringBuffer> sequences=structure.getSequences();
    for (    String sequencename : sequences.keySet()) {
      StringBuffer sequence=sequences.get(sequencename);
      if (length == -1) {
        length=sequence.length();
      }
 else       if (length != sequence.length()) {
        throw new RuntimeException("String_Node_Str");
      }
    }
  }
  return structure;
}