Program: 85414
Project: 85414
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);
      project.getOriginalModel().getProperties().setProperty("String_Node_Str","String_Node_Str");
    }
  }
  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<String,String> propertiesForPom=new LinkedHashMap<String,String>();
  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<String,String> properties=new LinkedHashMap<String,String>();
    if (propertiesContextHolder.get() != null) {
      properties=(LinkedHashMap)propertiesContextHolder.get();
    }
    for (    String key : propertiesForPom.keySet()) {
      if (!properties.containsKey(key)) {
        properties.put(key,propertiesForPom.get(key));
      }
    }
    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 adjustedPom=sb.toString();
    if (!project.getPackaging().equals("String_Node_Str") && !project.hasParent()) {
      adjustedPom=addPropertiesToPom(adjustedPom,sortedProperties);
    }
    adjustedPom=adjustLineEndingsForOS(adjustedPom);
    FileUtils.writeStringToFile(new File(pathToPom),adjustedPom);
  }
 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=propertiesContextHolder.get();
    Set<String> propertiesToAdd=new TreeSet<String>(properties.keySet());
    StringBuffer calculatedProperties=new StringBuffer();
    for (    String key : propertiesToAdd) {
      Set<Object> 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";
        }
        calculatedProperties.append("String_Node_Str");
        calculatedProperties.append(key);
        calculatedProperties.append("String_Node_Str");
        calculatedProperties.append(value);
        calculatedProperties.append("String_Node_Str");
        calculatedProperties.append(key);
        calculatedProperties.append("String_Node_Str");
        calculatedProperties.append("String_Node_Str");
      }
    }
    try {
      String originalPom=FileUtils.readFileToString(new File("String_Node_Str"));
      String pomWithProperties=addPropertiesToPom(originalPom,calculatedProperties);
      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);
      project.getOriginalModel().getProperties().setProperty("String_Node_Str","String_Node_Str");
    }
  }
  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<String,String> propertiesForPom=new LinkedHashMap<String,String>();
  for (  String key : projectProperties) {
    if (!currentKeys.contains(key)) {
      String value=appfuseProperties.getProperty(key);
      if (value == null) {
        continue;
      }
      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<String,String> properties=new LinkedHashMap<String,String>();
    if (propertiesContextHolder.get() != null) {
      properties=(LinkedHashMap)propertiesContextHolder.get();
    }
    for (    String key : propertiesForPom.keySet()) {
      if (!properties.containsKey(key)) {
        properties.put(key,propertiesForPom.get(key));
      }
    }
    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 adjustedPom=sb.toString();
    if (!project.getPackaging().equals("String_Node_Str") && !project.hasParent()) {
      adjustedPom=addPropertiesToPom(adjustedPom,sortedProperties);
    }
    adjustedPom=adjustLineEndingsForOS(adjustedPom);
    FileUtils.writeStringToFile(new File(pathToPom),adjustedPom);
  }
 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=propertiesContextHolder.get();
    Set<String> propertiesToAdd=new TreeSet<String>(properties.keySet());
    StringBuffer calculatedProperties=new StringBuffer();
    for (    String key : propertiesToAdd) {
      Set<Object> 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";
        }
        calculatedProperties.append("String_Node_Str");
        calculatedProperties.append(key);
        calculatedProperties.append("String_Node_Str");
        calculatedProperties.append(value);
        calculatedProperties.append("String_Node_Str");
        calculatedProperties.append(key);
        calculatedProperties.append("String_Node_Str");
        calculatedProperties.append("String_Node_Str");
      }
    }
    try {
      String originalPom=FileUtils.readFileToString(new File("String_Node_Str"));
      String pomWithProperties=addPropertiesToPom(originalPom,calculatedProperties);
      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();
  }
}