Program: 90226
Project: 90226
Buggy source:
/** 
 * Write a linux start script.
 * @param res               The file to write the script to
 * @param appName           the class name to start
 * @param settingsfn        the settings file to use
 * @param logpropDir        the directory to store the logging propertiesfile in
 * @param loggingProperties the content of the logging-properties file
 * @param extraOptions      Any extra options to the java process.  Theseoptions are inserted <em>before</em> the name of the Java class, so they cannot be used to pass command-line options to the application.
 */
private void writeStart(File res,String appName,String settingsfn,File logpropDir,String loggingProperties,String extraOptions){
  String logfn=writeLogPropertiesFile(appName,res.getParentFile(),logpropDir,loggingProperties);
  PrintWriter pw=null;
  PrintWriter pw2=null;
  try {
    try {
      pw=new PrintWriter(new FileWriter(res));
      String JVMARGS="String_Node_Str";
      String SETTINGSFILE="String_Node_Str" + Settings.SETTINGS_FILE_NAME_PROPERTY + "String_Node_Str"+ settingsfn;
      String LOGFILE="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ logfn;
      File JMXPasswordFile=new File(installDir + "String_Node_Str",Constants.JMX_PASSWORD_FILENAME);
      String JMXArgs=getJMXPortParameter() + "String_Node_Str" + JMXPasswordFile.getAbsolutePath();
      String httpFileTransferArgs=getHttpFileTransferArgs();
      String OPTIONS=extraOptions + "String_Node_Str" + SETTINGSFILE+ "String_Node_Str"+ LOGFILE+ "String_Node_Str"+ JMXArgs+ httpFileTransferArgs;
      pw.println("String_Node_Str");
      pw.println("String_Node_Str" + StringUtils.surjoin(getJarFiles(appName),installDir + "String_Node_Str","String_Node_Str") + "String_Node_Str");
      pw.println("String_Node_Str" + installDir);
      pw.println("String_Node_Str" + JVMARGS + "String_Node_Str"+ OPTIONS+ "String_Node_Str"+ appName+ "String_Node_Str"+ res.getName()+ "String_Node_Str");
      pw.close();
      String killAppName=res.getName().replaceAll("String_Node_Str","String_Node_Str");
      String[] temp=appName.split("String_Node_Str");
      appName=temp[0];
      pw2=new PrintWriter(new FileWriter(new File(res.getParentFile(),killAppName)));
      pw2.println("String_Node_Str");
      pw2.println("String_Node_Str" + appName + "String_Node_Str"+ settingsfn+ "String_Node_Str");
      pw2.println("String_Node_Str");
      pw2.println("String_Node_Str");
      pw2.println("String_Node_Str");
      if (HarvestControllerApplication.class.getName().equals(appName)) {
        pw2.println("String_Node_Str" + Heritrix.class.getName() + "String_Node_Str"+ settingsfn+ "String_Node_Str");
        pw2.println("String_Node_Str");
        pw2.println("String_Node_Str");
        pw2.println("String_Node_Str");
      }
      pw2.close();
      appsToStart.add(res.getName());
    }
  finally {
      if (pw != null) {
        pw.close();
      }
      if (pw2 != null) {
        pw2.close();
      }
    }
  }
 catch (  IOException e) {
    throw new IOFailure("String_Node_Str" + res + "String_Node_Str"+ appName,e);
  }
}

Fixed version (ground truth):
/** 
 * Write a linux start script.
 * @param res               The file to write the script to
 * @param appName           the class name to start
 * @param settingsfn        the settings file to use
 * @param logpropDir        the directory to store the logging propertiesfile in
 * @param loggingProperties the content of the logging-properties file
 * @param extraOptions      Any extra options to the java process.  Theseoptions are inserted <em>before</em> the name of the Java class, so they cannot be used to pass command-line options to the application.
 */
private void writeStart(File res,String appName,String settingsfn,File logpropDir,String loggingProperties,String extraOptions){
  String logfn=writeLogPropertiesFile(appName,res.getAbsoluteFile().getParentFile(),logpropDir,loggingProperties);
  PrintWriter pw=null;
  PrintWriter pw2=null;
  try {
    try {
      pw=new PrintWriter(new FileWriter(res));
      String JVMARGS="String_Node_Str";
      String SETTINGSFILE="String_Node_Str" + Settings.SETTINGS_FILE_NAME_PROPERTY + "String_Node_Str"+ settingsfn;
      String LOGFILE="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ logfn;
      File JMXPasswordFile=new File(installDir + "String_Node_Str",Constants.JMX_PASSWORD_FILENAME);
      String JMXArgs=getJMXPortParameter() + "String_Node_Str" + JMXPasswordFile.getAbsolutePath();
      String httpFileTransferArgs=getHttpFileTransferArgs();
      String OPTIONS=extraOptions + "String_Node_Str" + SETTINGSFILE+ "String_Node_Str"+ LOGFILE+ "String_Node_Str"+ JMXArgs+ httpFileTransferArgs;
      pw.println("String_Node_Str");
      pw.println("String_Node_Str" + StringUtils.surjoin(getJarFiles(appName),installDir + "String_Node_Str","String_Node_Str") + "String_Node_Str");
      pw.println("String_Node_Str" + installDir);
      pw.println("String_Node_Str" + JVMARGS + "String_Node_Str"+ OPTIONS+ "String_Node_Str"+ appName+ "String_Node_Str"+ res.getName()+ "String_Node_Str");
      pw.close();
      String killAppName=res.getName().replaceAll("String_Node_Str","String_Node_Str");
      String[] temp=appName.split("String_Node_Str");
      appName=temp[0];
      pw2=new PrintWriter(new FileWriter(new File(res.getAbsoluteFile().getParentFile(),killAppName)));
      pw2.println("String_Node_Str");
      pw2.println("String_Node_Str" + appName + "String_Node_Str"+ settingsfn+ "String_Node_Str");
      pw2.println("String_Node_Str");
      pw2.println("String_Node_Str");
      pw2.println("String_Node_Str");
      if (HarvestControllerApplication.class.getName().equals(appName)) {
        pw2.println("String_Node_Str" + Heritrix.class.getName() + "String_Node_Str"+ settingsfn+ "String_Node_Str");
        pw2.println("String_Node_Str");
        pw2.println("String_Node_Str");
        pw2.println("String_Node_Str");
      }
      pw2.close();
      appsToStart.add(res.getName());
    }
  finally {
      if (pw != null) {
        pw.close();
      }
      if (pw2 != null) {
        pw2.close();
      }
    }
  }
 catch (  IOException e) {
    throw new IOFailure("String_Node_Str" + res + "String_Node_Str"+ appName,e);
  }
}