Program: 90064
Project: 90064
Buggy source:
/** 
 * Copy inherited securityPolicyFile to local directory.
 * @param directory The local directory for this machine
 */
protected void createSecurityPolicyFile(File directory){
  ArgumentNotValid.checkNotNull(directory,"String_Node_Str");
  try {
    File secPolFile=new File(directory,"String_Node_Str");
    FileWriter secfw=new FileWriter(secPolFile);
    String prop=FileUtils.readFile(inheritedSecurityPolicyFile);
    String monitorRole=settings.getLeafValue(Constants.SETTINGS_JMX_PASSWORD_LEAF);
    if (monitorRole != null) {
      prop=prop.replace(Constants.SECURITY_JMX_PRINCIPAL_NAME_TAG,monitorRole);
    }
    String ctd=settings.getLeafValue(Constants.SETTINGS_TEMPDIR_LEAF);
    if (ctd != null) {
      prop=prop.replace(Constants.SECURITY_COMMON_TEMP_DIR_TAG,ctd);
    }
    secfw.write(prop);
    List<String> dirs=new ArrayList<String>();
    for (    Application app : applications) {
      String[] tmpDirs=app.getSettingsValues(Constants.SETTINGS_BITARCHIVE_FILEDIR_LEAF);
      if (tmpDirs != null && tmpDirs.length > 0) {
        for (        String st : tmpDirs) {
          dirs.add(st);
        }
      }
    }
    if (dirs.size() > 0) {
      secfw.write("String_Node_Str" + "String_Node_Str");
      for (      String dir : dirs) {
        secfw.write("String_Node_Str");
        secfw.write(changeFileDirPathForSecurity(dir));
        secfw.write("String_Node_Str");
        secfw.write("String_Node_Str" + "String_Node_Str");
      }
      secfw.write("String_Node_Str");
    }
    secfw.close();
  }
 catch (  IOException e) {
    log.warn("String_Node_Str" + e);
  }
}

Fixed version (ground truth):
/** 
 * Copy inherited securityPolicyFile to local directory.
 * @param directory The local directory for this machine
 */
protected void createSecurityPolicyFile(File directory){
  ArgumentNotValid.checkNotNull(directory,"String_Node_Str");
  try {
    File secPolFile=new File(directory,"String_Node_Str");
    FileWriter secfw=new FileWriter(secPolFile);
    String prop=FileUtils.readFile(inheritedSecurityPolicyFile);
    String monitorRole=settings.getLeafValue(Constants.SETTINGS_JMX_NAME_LEAF);
    if (monitorRole != null) {
      prop=prop.replace(Constants.SECURITY_JMX_PRINCIPAL_NAME_TAG,monitorRole);
    }
    String ctd=settings.getLeafValue(Constants.SETTINGS_TEMPDIR_LEAF);
    if (ctd != null) {
      prop=prop.replace(Constants.SECURITY_COMMON_TEMP_DIR_TAG,ctd);
    }
    secfw.write(prop);
    List<String> dirs=new ArrayList<String>();
    for (    Application app : applications) {
      String[] tmpDirs=app.getSettingsValues(Constants.SETTINGS_BITARCHIVE_FILEDIR_LEAF);
      if (tmpDirs != null && tmpDirs.length > 0) {
        for (        String st : tmpDirs) {
          dirs.add(st);
        }
      }
    }
    if (dirs.size() > 0) {
      secfw.write("String_Node_Str" + "String_Node_Str");
      for (      String dir : dirs) {
        secfw.write("String_Node_Str");
        secfw.write(changeFileDirPathForSecurity(dir));
        secfw.write("String_Node_Str");
        secfw.write("String_Node_Str" + "String_Node_Str");
      }
      secfw.write("String_Node_Str");
    }
    secfw.close();
  }
 catch (  IOException e) {
    log.warn("String_Node_Str" + e);
  }
}