Program: 85418
Project: 85418
Buggy source:
private void createFullSourcePom(List<Dependency> newDependencies) throws MojoFailureException {
  Set<String> projectProperties=new TreeSet<String>();
  for (  Dependency dep : newDependencies) {
    if (dep.getArtifactId().equals("String_Node_Str") || dep.getArtifactId().equals("String_Node_Str") || dep.getArtifactId().equals("String_Node_Str")|| dep.getArtifactId().equals("String_Node_Str")) {
      dep.setOptional(true);
      dep.setScope(null);
    }
    String version=dep.getVersion();
    if (version.startsWith("String_Node_Str")) {
      version=version.substring(2);
    }
    if (version.endsWith("String_Node_Str")) {
      version=version.substring(0,version.length() - 1);
    }
    projectProperties.add(version);
  }
  if (project.getPackaging().equals("String_Node_Str") && project.hasParent()) {
    Dependency core=new Dependency();
    core.setGroupId("String_Node_Str");
    core.setArtifactId("String_Node_Str");
    core.setVersion("String_Node_Str");
    newDependencies.add(core);
    if (project.getProperties().getProperty("String_Node_Str").equals("String_Node_Str")) {
      Dependency jsp21=new Dependency();
      jsp21.setGroupId("String_Node_Str");
      jsp21.setArtifactId("String_Node_Str");
      jsp21.setVersion("String_Node_Str");
      jsp21.setScope("String_Node_Str");
      newDependencies.add(jsp21);
    }
  }
  Collections.sort(newDependencies,new BeanComparator("String_Node_Str"));
  project.getOriginalModel().setDependencies(newDependencies);
  Properties currentProperties=project.getOriginalModel().getProperties();
  Set<String> currentKeys=new LinkedHashSet<String>();
  for (  Object key : currentProperties.keySet()) {
    currentKeys.add((String)key);
  }
  StringBuffer sortedProperties=new StringBuffer();
  Properties appfuseProperties=getAppFuseProperties();
  Map propertiesForPom=new LinkedHashMap();
  for (  String key : projectProperties) {
    if (!currentKeys.contains(key)) {
      String value=appfuseProperties.getProperty(key);
      if (value.contains("String_Node_Str")) {
        value="String_Node_Str" + value + "String_Node_Str";
      }
      sortedProperties.append("String_Node_Str").append(key).append("String_Node_Str").append(value).append("String_Node_Str").append(key).append("String_Node_Str" + "String_Node_Str");
      propertiesForPom.put(key,value);
    }
  }
  if (project.getPackaging().equals("String_Node_Str") || project.hasParent()) {
    Map properties=new LinkedHashMap();
    if (propertiesContextHolder.get() != null) {
      properties=(LinkedHashMap)propertiesContextHolder.get();
    }
    properties.putAll(propertiesForPom);
    propertiesContextHolder.set(properties);
  }
  StringWriter writer=new StringWriter();
  try {
    project.writeOriginalModel(writer);
    File pom=new File("String_Node_Str");
    if (pom.exists()) {
      pom.delete();
    }
    FileWriter fw=new FileWriter(pom);
    fw.write(writer.toString());
    fw.flush();
    fw.close();
  }
 catch (  IOException ex) {
    getLog().error("String_Node_Str" + ex.getMessage(),ex);
    throw new MojoFailureException(ex.getMessage());
  }
  log("String_Node_Str");
  String pomXml=writer.toString();
  int startTag=pomXml.indexOf("String_Node_Str");
  String dependencyXml=pomXml.substring(startTag,pomXml.indexOf("String_Node_Str",startTag));
  dependencyXml=dependencyXml.replaceAll("String_Node_Str","String_Node_Str");
  dependencyXml="String_Node_Str" + dependencyXml;
  try {
    String packaging=project.getPackaging();
    String pathToPom="String_Node_Str";
    if (project.hasParent()) {
      if (packaging.equals("String_Node_Str")) {
        pathToPom="String_Node_Str" + pathToPom;
      }
 else       if (packaging.equals("String_Node_Str")) {
        pathToPom="String_Node_Str" + pathToPom;
      }
    }
    String originalPom=FileUtils.readFileToString(new File(pathToPom));
    startTag=originalPom.indexOf("String_Node_Str");
    StringBuffer sb=new StringBuffer();
    sb.append(originalPom.substring(0,startTag));
    sb.append(dependencyXml);
    sb.append(originalPom.substring(originalPom.indexOf("String_Node_Str",startTag)));
    String pomWithProperties=sb.toString().replace("String_Node_Str","String_Node_Str" + sortedProperties + "String_Node_Str");
    pomWithProperties=pomWithProperties.replaceAll("String_Node_Str","String_Node_Str");
    String os=System.getProperty("String_Node_Str");
    if (os.startsWith("String_Node_Str") || os.startsWith("String_Node_Str")) {
      pomWithProperties=pomWithProperties.replaceAll("String_Node_Str","String_Node_Str");
    }
    FileUtils.writeStringToFile(new File(pathToPom),pomWithProperties);
  }
 catch (  IOException ex) {
    getLog().error("String_Node_Str" + ex.getMessage(),ex);
    throw new MojoFailureException(ex.getMessage());
  }
  boolean renamePackages=true;
  if (System.getProperty("String_Node_Str") != null) {
    renamePackages=Boolean.valueOf(System.getProperty("String_Node_Str"));
  }
  if (renamePackages && !project.getPackaging().equals("String_Node_Str")) {
    log("String_Node_Str" + project.getGroupId() + "String_Node_Str");
    RenamePackages renamePackagesTool=new RenamePackages(project.getGroupId());
    if (project.hasParent()) {
      if (project.getPackaging().equals("String_Node_Str")) {
        renamePackagesTool.setBaseDir("String_Node_Str");
      }
 else {
        renamePackagesTool.setBaseDir("String_Node_Str");
      }
    }
    renamePackagesTool.execute();
  }
  if (project.getPackaging().equals("String_Node_Str") && project.hasParent()) {
    Map properties=(Map)propertiesContextHolder.get();
    Set<String> propertiesToAdd=new TreeSet<String>(properties.keySet());
    for (    String key : propertiesToAdd) {
      Set keysInProject=project.getParent().getOriginalModel().getProperties().keySet();
      if (!keysInProject.contains(key)) {
        String value=getAppFuseProperties().getProperty(key);
        if (value.contains("String_Node_Str")) {
          value="String_Node_Str" + value + "String_Node_Str";
        }
        sortedProperties.append("String_Node_Str").append(key).append("String_Node_Str").append(value).append("String_Node_Str").append(key).append("String_Node_Str" + "String_Node_Str");
      }
    }
    try {
      String originalPom=FileUtils.readFileToString(new File("String_Node_Str"));
      String pomWithProperties=originalPom.replace("String_Node_Str","String_Node_Str" + sortedProperties + "String_Node_Str");
      pomWithProperties=pomWithProperties.replaceAll("String_Node_Str","String_Node_Str");
      String os=System.getProperty("String_Node_Str");
      if (os.startsWith("String_Node_Str") || os.startsWith("String_Node_Str")) {
        pomWithProperties=pomWithProperties.replaceAll("String_Node_Str","String_Node_Str");
      }
      FileUtils.writeStringToFile(new File("String_Node_Str"),pomWithProperties);
    }
 catch (    IOException ex) {
      getLog().error("String_Node_Str" + ex.getMessage(),ex);
      throw new MojoFailureException(ex.getMessage());
    }
  }
  File pom=new File("String_Node_Str");
  if (pom.exists()) {
    pom.delete();
  }
}

Fixed version (ground truth):
private void createFullSourcePom(List<Dependency> newDependencies) throws MojoFailureException {
  Set<String> projectProperties=new TreeSet<String>();
  for (  Dependency dep : newDependencies) {
    if (dep.getArtifactId().equals("String_Node_Str") || dep.getArtifactId().equals("String_Node_Str") || dep.getArtifactId().equals("String_Node_Str")|| dep.getArtifactId().equals("String_Node_Str")) {
      dep.setOptional(true);
      dep.setScope(null);
    }
    String version=dep.getVersion();
    if (version.startsWith("String_Node_Str")) {
      version=version.substring(2);
    }
    if (version.endsWith("String_Node_Str")) {
      version=version.substring(0,version.length() - 1);
    }
    projectProperties.add(version);
  }
  if (project.getPackaging().equals("String_Node_Str") && project.hasParent()) {
    Dependency core=new Dependency();
    core.setGroupId("String_Node_Str");
    core.setArtifactId("String_Node_Str");
    core.setVersion("String_Node_Str");
    newDependencies.add(core);
    if (project.getProperties().getProperty("String_Node_Str").equals("String_Node_Str")) {
      Dependency jsp21=new Dependency();
      jsp21.setGroupId("String_Node_Str");
      jsp21.setArtifactId("String_Node_Str");
      jsp21.setVersion("String_Node_Str");
      jsp21.setScope("String_Node_Str");
      newDependencies.add(jsp21);
    }
  }
  Collections.sort(newDependencies,new BeanComparator("String_Node_Str"));
  project.getOriginalModel().setDependencies(newDependencies);
  Properties currentProperties=project.getOriginalModel().getProperties();
  Set<String> currentKeys=new LinkedHashSet<String>();
  for (  Object key : currentProperties.keySet()) {
    currentKeys.add((String)key);
  }
  StringBuffer sortedProperties=new StringBuffer();
  Properties appfuseProperties=getAppFuseProperties();
  Map propertiesForPom=new LinkedHashMap();
  for (  String key : projectProperties) {
    if (!currentKeys.contains(key)) {
      String value=appfuseProperties.getProperty(key);
      if (value.contains("String_Node_Str")) {
        value="String_Node_Str" + value + "String_Node_Str";
      }
      sortedProperties.append("String_Node_Str").append(key).append("String_Node_Str").append(value).append("String_Node_Str").append(key).append("String_Node_Str" + "String_Node_Str");
      propertiesForPom.put(key,value);
    }
  }
  if (project.getPackaging().equals("String_Node_Str") || project.hasParent()) {
    Map properties=new LinkedHashMap();
    if (propertiesContextHolder.get() != null) {
      properties=(LinkedHashMap)propertiesContextHolder.get();
    }
    properties.putAll(propertiesForPom);
    propertiesContextHolder.set(properties);
  }
  StringWriter writer=new StringWriter();
  try {
    project.writeOriginalModel(writer);
    File pom=new File("String_Node_Str");
    if (pom.exists()) {
      pom.delete();
    }
    FileWriter fw=new FileWriter(pom);
    fw.write(writer.toString());
    fw.flush();
    fw.close();
  }
 catch (  IOException ex) {
    getLog().error("String_Node_Str" + ex.getMessage(),ex);
    throw new MojoFailureException(ex.getMessage());
  }
  log("String_Node_Str");
  String pomXml=writer.toString();
  int startTag=pomXml.indexOf("String_Node_Str");
  String dependencyXml=pomXml.substring(startTag,pomXml.indexOf("String_Node_Str",startTag));
  dependencyXml=dependencyXml.replaceAll("String_Node_Str","String_Node_Str");
  dependencyXml="String_Node_Str" + dependencyXml;
  try {
    String packaging=project.getPackaging();
    String pathToPom="String_Node_Str";
    if (project.hasParent()) {
      if (packaging.equals("String_Node_Str")) {
        pathToPom="String_Node_Str" + pathToPom;
      }
 else       if (packaging.equals("String_Node_Str")) {
        pathToPom="String_Node_Str" + pathToPom;
      }
    }
    String originalPom=FileUtils.readFileToString(new File(pathToPom));
    startTag=originalPom.indexOf("String_Node_Str");
    StringBuffer sb=new StringBuffer();
    sb.append(originalPom.substring(0,startTag));
    sb.append(dependencyXml);
    sb.append(originalPom.substring(originalPom.indexOf("String_Node_Str",startTag)));
    if (sb.lastIndexOf("String_Node_Str") > -1) {
      String pomWithProperties=sb.substring(0,sb.lastIndexOf("String_Node_Str"));
      pomWithProperties+="String_Node_Str" + sortedProperties + "String_Node_Str";
      pomWithProperties=pomWithProperties.replaceAll("String_Node_Str","String_Node_Str");
      String os=System.getProperty("String_Node_Str");
      if (os.startsWith("String_Node_Str") || os.startsWith("String_Node_Str")) {
        pomWithProperties=pomWithProperties.replaceAll("String_Node_Str","String_Node_Str");
      }
      FileUtils.writeStringToFile(new File(pathToPom),pomWithProperties);
    }
  }
 catch (  IOException ex) {
    getLog().error("String_Node_Str" + ex.getMessage(),ex);
    throw new MojoFailureException(ex.getMessage());
  }
  boolean renamePackages=true;
  if (System.getProperty("String_Node_Str") != null) {
    renamePackages=Boolean.valueOf(System.getProperty("String_Node_Str"));
  }
  if (renamePackages && !project.getPackaging().equals("String_Node_Str")) {
    log("String_Node_Str" + project.getGroupId() + "String_Node_Str");
    RenamePackages renamePackagesTool=new RenamePackages(project.getGroupId());
    if (project.hasParent()) {
      if (project.getPackaging().equals("String_Node_Str")) {
        renamePackagesTool.setBaseDir("String_Node_Str");
      }
 else {
        renamePackagesTool.setBaseDir("String_Node_Str");
      }
    }
    renamePackagesTool.execute();
  }
  if (project.getPackaging().equals("String_Node_Str") && project.hasParent()) {
    Map properties=(Map)propertiesContextHolder.get();
    Set<String> propertiesToAdd=new TreeSet<String>(properties.keySet());
    for (    String key : propertiesToAdd) {
      Set keysInProject=project.getParent().getOriginalModel().getProperties().keySet();
      if (!keysInProject.contains(key)) {
        String value=getAppFuseProperties().getProperty(key);
        if (value.contains("String_Node_Str")) {
          value="String_Node_Str" + value + "String_Node_Str";
        }
        sortedProperties.append("String_Node_Str").append(key).append("String_Node_Str").append(value).append("String_Node_Str").append(key).append("String_Node_Str" + "String_Node_Str");
      }
    }
    try {
      String originalPom=FileUtils.readFileToString(new File("String_Node_Str"));
      String pomWithProperties=originalPom.replace("String_Node_Str","String_Node_Str" + sortedProperties + "String_Node_Str");
      pomWithProperties=pomWithProperties.replaceAll("String_Node_Str","String_Node_Str");
      String os=System.getProperty("String_Node_Str");
      if (os.startsWith("String_Node_Str") || os.startsWith("String_Node_Str")) {
        pomWithProperties=pomWithProperties.replaceAll("String_Node_Str","String_Node_Str");
      }
      FileUtils.writeStringToFile(new File("String_Node_Str"),pomWithProperties);
    }
 catch (    IOException ex) {
      getLog().error("String_Node_Str" + ex.getMessage(),ex);
      throw new MojoFailureException(ex.getMessage());
    }
  }
  File pom=new File("String_Node_Str");
  if (pom.exists()) {
    pom.delete();
  }
}