Program: 16017
Project: 16017
Buggy source:
/** 
 * Converts a trace file to a Java class file and a script file.
 * @param traceFileName
 * @param javaClassName
 * @throws IOException
 */
private void convertFile(String traceFileName,String javaClassName,String script) throws IOException {
  LineNumberReader reader=new LineNumberReader(IOUtils.getBufferedReader(IOUtils.openFileInputStream(traceFileName)));
  PrintWriter javaWriter=new PrintWriter(IOUtils.getBufferedWriter(IOUtils.openFileOutputStream(javaClassName + "String_Node_Str",false)));
  PrintWriter scriptWriter=new PrintWriter(IOUtils.getBufferedWriter(IOUtils.openFileOutputStream(script,false)));
  javaWriter.println("String_Node_Str");
  javaWriter.println("String_Node_Str");
  javaWriter.println("String_Node_Str");
  javaWriter.println("String_Node_Str");
  String cn=javaClassName.replace('\\','/');
  int idx=cn.lastIndexOf('/');
  if (idx > 0) {
    cn=cn.substring(idx + 1);
  }
  javaWriter.println("String_Node_Str" + cn + "String_Node_Str");
  javaWriter.println("String_Node_Str");
  javaWriter.println("String_Node_Str");
  while (true) {
    String line=reader.readLine();
    if (line == null) {
      break;
    }
    if (line.startsWith("String_Node_Str")) {
      line="String_Node_Str" + line.substring(4);
      javaWriter.println(line);
    }
 else     if (line.startsWith("String_Node_Str")) {
      int end=line.indexOf("String_Node_Str");
      String sql=line.substring(end + "String_Node_Str".length());
      sql=StringUtils.javaDecode(sql);
      line=line.substring("String_Node_Str".length(),end);
      if (line.length() > 0) {
        String statement=sql;
        int count=0;
        int time=0;
        line=line.trim();
        if (line.length() > 0) {
          StringTokenizer tk=new StringTokenizer(line,"String_Node_Str");
          while (tk.hasMoreElements()) {
            String token=tk.nextToken();
            if ("String_Node_Str".equals(token)) {
              int len=Integer.parseInt(tk.nextToken());
              statement=sql.substring(0,len) + "String_Node_Str";
            }
 else             if ("String_Node_Str".equals(token)) {
              count=Integer.parseInt(tk.nextToken());
            }
 else             if ("String_Node_Str".equals(token)) {
              time=Integer.parseInt(tk.nextToken());
            }
          }
        }
        addToStats(statement,count,time);
      }
      scriptWriter.println(sql);
    }
  }
  javaWriter.println("String_Node_Str");
  javaWriter.println("String_Node_Str");
  reader.close();
  javaWriter.close();
  if (stats.size() > 0) {
    scriptWriter.println("String_Node_Str");
    scriptWriter.println("String_Node_Str");
    scriptWriter.println("String_Node_Str");
    scriptWriter.println("String_Node_Str");
    scriptWriter.println("String_Node_Str");
    scriptWriter.println("String_Node_Str");
    scriptWriter.println("String_Node_Str");
    int accumTime=0;
    ArrayList<Stat> list=New.arrayList(stats.values());
    Collections.sort(list);
    if (timeTotal == 0) {
      timeTotal=1;
    }
    for (    Stat stat : list) {
      accumTime+=stat.time;
      StringBuilder buff=new StringBuilder(100);
      buff.append("String_Node_Str").append(padNumberLeft(100 * stat.time / timeTotal,3)).append("String_Node_Str").append(padNumberLeft(100 * accumTime / timeTotal,3)).append('%').append(padNumberLeft(stat.time,8)).append(padNumberLeft(stat.executeCount,8)).append(padNumberLeft(stat.resultCount,8)).append(' ').append(removeNewlines(stat.sql));
      scriptWriter.println(buff.toString());
    }
  }
  scriptWriter.close();
}

Fixed version (ground truth):
/** 
 * Converts a trace file to a Java class file and a script file.
 * @param traceFileName
 * @param javaClassName
 * @throws IOException
 */
private void convertFile(String traceFileName,String javaClassName,String script) throws IOException {
  LineNumberReader reader=new LineNumberReader(IOUtils.getBufferedReader(IOUtils.openFileInputStream(traceFileName)));
  PrintWriter javaWriter=new PrintWriter(IOUtils.getBufferedWriter(IOUtils.openFileOutputStream(javaClassName + "String_Node_Str",false)));
  PrintWriter scriptWriter=new PrintWriter(IOUtils.getBufferedWriter(IOUtils.openFileOutputStream(script,false)));
  javaWriter.println("String_Node_Str");
  javaWriter.println("String_Node_Str");
  javaWriter.println("String_Node_Str");
  javaWriter.println("String_Node_Str");
  String cn=javaClassName.replace('\\','/');
  int idx=cn.lastIndexOf('/');
  if (idx > 0) {
    cn=cn.substring(idx + 1);
  }
  javaWriter.println("String_Node_Str" + cn + "String_Node_Str");
  javaWriter.println("String_Node_Str");
  javaWriter.println("String_Node_Str");
  while (true) {
    String line=reader.readLine();
    if (line == null) {
      break;
    }
    if (line.startsWith("String_Node_Str")) {
      line="String_Node_Str" + line.substring(4);
      javaWriter.println(line);
    }
 else     if (line.startsWith("String_Node_Str")) {
      int end=line.indexOf("String_Node_Str");
      String sql=line.substring(end + "String_Node_Str".length());
      sql=StringUtils.javaDecode(sql);
      line=line.substring("String_Node_Str".length(),end);
      if (line.length() > 0) {
        String statement=sql;
        int count=0;
        int time=0;
        line=line.trim();
        if (line.length() > 0) {
          StringTokenizer tk=new StringTokenizer(line,"String_Node_Str");
          while (tk.hasMoreElements()) {
            String token=tk.nextToken();
            if ("String_Node_Str".equals(token)) {
              int len=Integer.parseInt(tk.nextToken());
              statement=sql.substring(0,len) + "String_Node_Str";
            }
 else             if ("String_Node_Str".equals(token)) {
              count=Integer.parseInt(tk.nextToken());
            }
 else             if ("String_Node_Str".equals(token)) {
              time=Integer.parseInt(tk.nextToken());
            }
          }
        }
        addToStats(statement,count,time);
      }
      scriptWriter.println(sql);
    }
  }
  javaWriter.println("String_Node_Str");
  javaWriter.println('}');
  reader.close();
  javaWriter.close();
  if (stats.size() > 0) {
    scriptWriter.println("String_Node_Str");
    scriptWriter.println("String_Node_Str");
    scriptWriter.println("String_Node_Str");
    scriptWriter.println("String_Node_Str");
    scriptWriter.println("String_Node_Str");
    scriptWriter.println("String_Node_Str");
    scriptWriter.println("String_Node_Str");
    int accumTime=0;
    ArrayList<Stat> list=New.arrayList(stats.values());
    Collections.sort(list);
    if (timeTotal == 0) {
      timeTotal=1;
    }
    for (    Stat stat : list) {
      accumTime+=stat.time;
      StringBuilder buff=new StringBuilder(100);
      buff.append("String_Node_Str").append(padNumberLeft(100 * stat.time / timeTotal,3)).append("String_Node_Str").append(padNumberLeft(100 * accumTime / timeTotal,3)).append('%').append(padNumberLeft(stat.time,8)).append(padNumberLeft(stat.executeCount,8)).append(padNumberLeft(stat.resultCount,8)).append(' ').append(removeNewlines(stat.sql));
      scriptWriter.println(buff.toString());
    }
  }
  scriptWriter.close();
}