Program: 171347
Project: 171347
Buggy source:
public void savePropertiesAsXML(){
  try {
    DocumentBuilderFactory docFactory=DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder=docFactory.newDocumentBuilder();
    Document doc=docBuilder.newDocument();
    Element properties=doc.createElement("String_Node_Str");
    doc.appendChild(properties);
    Element previousSave=doc.createElement("String_Node_Str");
    properties.appendChild(previousSave);
    createXMLElementWithValue(doc,previousSave,"String_Node_Str",lastSaveLocation);
    createXMLElementWithValue(doc,previousSave,"String_Node_Str",nameColour);
    createXMLElementWithValue(doc,previousSave,"String_Node_Str",name);
    createXMLElementWithValue(doc,previousSave,"String_Node_Str",race);
    createXMLElementWithValue(doc,previousSave,"String_Node_Str",quest);
    createXMLElementWithValue(doc,previousSave,"String_Node_Str",String.valueOf(level));
    createXMLElementWithValue(doc,previousSave,"String_Node_Str",String.valueOf(money));
    createXMLElementWithValue(doc,previousSave,"String_Node_Str",Main.VERSION_NUMBER);
    createXMLElementWithValue(doc,previousSave,"String_Node_Str",lastQuickSaveName);
    Element settings=doc.createElement("String_Node_Str");
    properties.appendChild(settings);
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(fontSize));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(lightTheme));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(furryTailPenetrationContent));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(nonConContent));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(incestContent));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(facialHairContent));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(pubicHairContent));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(bodyHairContent));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(overwriteWarning));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(fadeInText));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(androgynousIdentification));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(humanEncountersLevel));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(multiBreasts));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(newWeaponDiscovered));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(newClothingDiscovered));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(newItemDiscovered));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(newRaceDiscovered));
    Element keyBinds=doc.createElement("String_Node_Str");
    properties.appendChild(keyBinds);
    for (    KeyboardAction ka : KeyboardAction.values()) {
      Element element=doc.createElement("String_Node_Str");
      keyBinds.appendChild(element);
      Attr bindName=doc.createAttribute("String_Node_Str");
      bindName.setValue(ka.toString());
      element.setAttributeNode(bindName);
      Attr primaryBind=doc.createAttribute("String_Node_Str");
      if (hotkeyMapPrimary.get(ka) != null)       primaryBind.setValue(hotkeyMapPrimary.get(ka).toString());
 else       primaryBind.setValue("String_Node_Str");
      element.setAttributeNode(primaryBind);
      Attr secondaryBind=doc.createAttribute("String_Node_Str");
      if (hotkeyMapSecondary.get(ka) != null)       secondaryBind.setValue(hotkeyMapSecondary.get(ka).toString());
 else       secondaryBind.setValue("String_Node_Str");
      element.setAttributeNode(secondaryBind);
    }
    Element genderNames=doc.createElement("String_Node_Str");
    properties.appendChild(genderNames);
    for (    GenderNames gp : GenderNames.values()) {
      Element element=doc.createElement("String_Node_Str");
      genderNames.appendChild(element);
      Attr pronounName=doc.createAttribute("String_Node_Str");
      pronounName.setValue(gp.toString());
      element.setAttributeNode(pronounName);
      Attr feminineValue=doc.createAttribute("String_Node_Str");
      if (genderNameFemale.get(gp) != null) {
        feminineValue.setValue(genderNameFemale.get(gp));
      }
 else {
        feminineValue.setValue(gp.getFeminine());
      }
      element.setAttributeNode(feminineValue);
      Attr masculineValue=doc.createAttribute("String_Node_Str");
      if (genderNameMale.get(gp) != null) {
        masculineValue.setValue(genderNameMale.get(gp));
      }
 else {
        masculineValue.setValue(gp.getMasculine());
      }
      element.setAttributeNode(masculineValue);
      Attr neutralValue=doc.createAttribute("String_Node_Str");
      if (genderNameNeutral.get(gp) != null) {
        neutralValue.setValue(genderNameNeutral.get(gp));
      }
 else {
        neutralValue.setValue(gp.getNeutral());
      }
      element.setAttributeNode(neutralValue);
    }
    Element pronouns=doc.createElement("String_Node_Str");
    properties.appendChild(pronouns);
    for (    GenderPronoun gp : GenderPronoun.values()) {
      Element element=doc.createElement("String_Node_Str");
      pronouns.appendChild(element);
      Attr pronounName=doc.createAttribute("String_Node_Str");
      pronounName.setValue(gp.toString());
      element.setAttributeNode(pronounName);
      Attr feminineValue=doc.createAttribute("String_Node_Str");
      if (genderPronounFemale.get(gp) != null)       feminineValue.setValue(genderPronounFemale.get(gp));
 else       feminineValue.setValue(gp.getFeminine());
      element.setAttributeNode(feminineValue);
      Attr masculineValue=doc.createAttribute("String_Node_Str");
      if (genderPronounMale.get(gp) != null)       masculineValue.setValue(genderPronounMale.get(gp));
 else       masculineValue.setValue(gp.getMasculine());
      element.setAttributeNode(masculineValue);
    }
    Element genderPreferences=doc.createElement("String_Node_Str");
    properties.appendChild(genderPreferences);
    for (    Gender g : Gender.values()) {
      Element element=doc.createElement("String_Node_Str");
      genderPreferences.appendChild(element);
      Attr gender=doc.createAttribute("String_Node_Str");
      gender.setValue(g.toString());
      element.setAttributeNode(gender);
      Attr value=doc.createAttribute("String_Node_Str");
      value.setValue(String.valueOf(genderPreferencesMap.get(g).intValue()));
      element.setAttributeNode(value);
    }
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(forcedTFPreference));
    Element racePreferences=doc.createElement("String_Node_Str");
    properties.appendChild(racePreferences);
    for (    Race r : Race.values()) {
      Element element=doc.createElement("String_Node_Str");
      racePreferences.appendChild(element);
      Attr race=doc.createAttribute("String_Node_Str");
      race.setValue(r.toString());
      element.setAttributeNode(race);
      Attr preference=doc.createAttribute("String_Node_Str");
      preference.setValue(raceFemininePreferencesMap.get(r).toString());
      element.setAttributeNode(preference);
      element=doc.createElement("String_Node_Str");
      racePreferences.appendChild(element);
      race=doc.createAttribute("String_Node_Str");
      race.setValue(r.toString());
      element.setAttributeNode(race);
      preference=doc.createAttribute("String_Node_Str");
      preference.setValue(raceMasculinePreferencesMap.get(r).toString());
      element.setAttributeNode(preference);
    }
    Element itemsDiscovered=doc.createElement("String_Node_Str");
    properties.appendChild(itemsDiscovered);
    for (    AbstractItemType itemType : this.itemsDiscovered) {
      Element element=doc.createElement("String_Node_Str");
      itemsDiscovered.appendChild(element);
      Attr hash=doc.createAttribute("String_Node_Str");
      hash.setValue(itemType.getId());
      element.setAttributeNode(hash);
    }
    Element weaponsDiscovered=doc.createElement("String_Node_Str");
    properties.appendChild(weaponsDiscovered);
    for (    AbstractWeaponType weaponType : this.weaponsDiscovered) {
      Element element=doc.createElement("String_Node_Str");
      weaponsDiscovered.appendChild(element);
      Attr hash=doc.createAttribute("String_Node_Str");
      hash.setValue(weaponType.getId());
      element.setAttributeNode(hash);
    }
    Element clothingDiscovered=doc.createElement("String_Node_Str");
    properties.appendChild(clothingDiscovered);
    for (    AbstractClothingType clothingType : this.clothingDiscovered) {
      Element element=doc.createElement("String_Node_Str");
      clothingDiscovered.appendChild(element);
      Attr hash=doc.createAttribute("String_Node_Str");
      if (clothingType != null)       hash.setValue(clothingType.getId());
      element.setAttributeNode(hash);
    }
    Element racesDiscovered=doc.createElement("String_Node_Str");
    properties.appendChild(racesDiscovered);
    for (    Race race : Race.values()) {
      Element element=doc.createElement("String_Node_Str");
      racesDiscovered.appendChild(element);
      Attr discovered=doc.createAttribute("String_Node_Str");
      discovered.setValue(race.toString());
      element.setAttributeNode(discovered);
      discovered=doc.createAttribute("String_Node_Str");
      discovered.setValue(String.valueOf(this.racesDiscovered.contains(race)));
      element.setAttributeNode(discovered);
      discovered=doc.createAttribute("String_Node_Str");
      discovered.setValue(String.valueOf(this.racesAdvancedKnowledge.contains(race)));
      element.setAttributeNode(discovered);
    }
    TransformerFactory transformerFactory=TransformerFactory.newInstance();
    Transformer transformer=transformerFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT,"String_Node_Str");
    transformer.setOutputProperty("String_Node_Str","String_Node_Str");
    DOMSource source=new DOMSource(doc);
    StreamResult result=new StreamResult(new File("String_Node_Str"));
    transformer.transform(source,result);
  }
 catch (  ParserConfigurationException|TransformerException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public void savePropertiesAsXML(){
  try {
    DocumentBuilderFactory docFactory=DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder=docFactory.newDocumentBuilder();
    Document doc=docBuilder.newDocument();
    Element properties=doc.createElement("String_Node_Str");
    doc.appendChild(properties);
    Element previousSave=doc.createElement("String_Node_Str");
    properties.appendChild(previousSave);
    createXMLElementWithValue(doc,previousSave,"String_Node_Str",lastSaveLocation);
    createXMLElementWithValue(doc,previousSave,"String_Node_Str",nameColour);
    createXMLElementWithValue(doc,previousSave,"String_Node_Str",name);
    createXMLElementWithValue(doc,previousSave,"String_Node_Str",race);
    createXMLElementWithValue(doc,previousSave,"String_Node_Str",quest);
    createXMLElementWithValue(doc,previousSave,"String_Node_Str",String.valueOf(level));
    createXMLElementWithValue(doc,previousSave,"String_Node_Str",String.valueOf(money));
    createXMLElementWithValue(doc,previousSave,"String_Node_Str",String.valueOf(arcaneEssences));
    createXMLElementWithValue(doc,previousSave,"String_Node_Str",Main.VERSION_NUMBER);
    createXMLElementWithValue(doc,previousSave,"String_Node_Str",lastQuickSaveName);
    Element settings=doc.createElement("String_Node_Str");
    properties.appendChild(settings);
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(fontSize));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(lightTheme));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(furryTailPenetrationContent));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(nonConContent));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(incestContent));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(facialHairContent));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(pubicHairContent));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(bodyHairContent));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(overwriteWarning));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(fadeInText));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(androgynousIdentification));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(humanEncountersLevel));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(multiBreasts));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(newWeaponDiscovered));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(newClothingDiscovered));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(newItemDiscovered));
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(newRaceDiscovered));
    Element keyBinds=doc.createElement("String_Node_Str");
    properties.appendChild(keyBinds);
    for (    KeyboardAction ka : KeyboardAction.values()) {
      Element element=doc.createElement("String_Node_Str");
      keyBinds.appendChild(element);
      Attr bindName=doc.createAttribute("String_Node_Str");
      bindName.setValue(ka.toString());
      element.setAttributeNode(bindName);
      Attr primaryBind=doc.createAttribute("String_Node_Str");
      if (hotkeyMapPrimary.get(ka) != null)       primaryBind.setValue(hotkeyMapPrimary.get(ka).toString());
 else       primaryBind.setValue("String_Node_Str");
      element.setAttributeNode(primaryBind);
      Attr secondaryBind=doc.createAttribute("String_Node_Str");
      if (hotkeyMapSecondary.get(ka) != null)       secondaryBind.setValue(hotkeyMapSecondary.get(ka).toString());
 else       secondaryBind.setValue("String_Node_Str");
      element.setAttributeNode(secondaryBind);
    }
    Element genderNames=doc.createElement("String_Node_Str");
    properties.appendChild(genderNames);
    for (    GenderNames gp : GenderNames.values()) {
      Element element=doc.createElement("String_Node_Str");
      genderNames.appendChild(element);
      Attr pronounName=doc.createAttribute("String_Node_Str");
      pronounName.setValue(gp.toString());
      element.setAttributeNode(pronounName);
      Attr feminineValue=doc.createAttribute("String_Node_Str");
      if (genderNameFemale.get(gp) != null) {
        feminineValue.setValue(genderNameFemale.get(gp));
      }
 else {
        feminineValue.setValue(gp.getFeminine());
      }
      element.setAttributeNode(feminineValue);
      Attr masculineValue=doc.createAttribute("String_Node_Str");
      if (genderNameMale.get(gp) != null) {
        masculineValue.setValue(genderNameMale.get(gp));
      }
 else {
        masculineValue.setValue(gp.getMasculine());
      }
      element.setAttributeNode(masculineValue);
      Attr neutralValue=doc.createAttribute("String_Node_Str");
      if (genderNameNeutral.get(gp) != null) {
        neutralValue.setValue(genderNameNeutral.get(gp));
      }
 else {
        neutralValue.setValue(gp.getNeutral());
      }
      element.setAttributeNode(neutralValue);
    }
    Element pronouns=doc.createElement("String_Node_Str");
    properties.appendChild(pronouns);
    for (    GenderPronoun gp : GenderPronoun.values()) {
      Element element=doc.createElement("String_Node_Str");
      pronouns.appendChild(element);
      Attr pronounName=doc.createAttribute("String_Node_Str");
      pronounName.setValue(gp.toString());
      element.setAttributeNode(pronounName);
      Attr feminineValue=doc.createAttribute("String_Node_Str");
      if (genderPronounFemale.get(gp) != null)       feminineValue.setValue(genderPronounFemale.get(gp));
 else       feminineValue.setValue(gp.getFeminine());
      element.setAttributeNode(feminineValue);
      Attr masculineValue=doc.createAttribute("String_Node_Str");
      if (genderPronounMale.get(gp) != null)       masculineValue.setValue(genderPronounMale.get(gp));
 else       masculineValue.setValue(gp.getMasculine());
      element.setAttributeNode(masculineValue);
    }
    Element genderPreferences=doc.createElement("String_Node_Str");
    properties.appendChild(genderPreferences);
    for (    Gender g : Gender.values()) {
      Element element=doc.createElement("String_Node_Str");
      genderPreferences.appendChild(element);
      Attr gender=doc.createAttribute("String_Node_Str");
      gender.setValue(g.toString());
      element.setAttributeNode(gender);
      Attr value=doc.createAttribute("String_Node_Str");
      value.setValue(String.valueOf(genderPreferencesMap.get(g).intValue()));
      element.setAttributeNode(value);
    }
    createXMLElementWithValue(doc,settings,"String_Node_Str",String.valueOf(forcedTFPreference));
    Element racePreferences=doc.createElement("String_Node_Str");
    properties.appendChild(racePreferences);
    for (    Race r : Race.values()) {
      Element element=doc.createElement("String_Node_Str");
      racePreferences.appendChild(element);
      Attr race=doc.createAttribute("String_Node_Str");
      race.setValue(r.toString());
      element.setAttributeNode(race);
      Attr preference=doc.createAttribute("String_Node_Str");
      preference.setValue(raceFemininePreferencesMap.get(r).toString());
      element.setAttributeNode(preference);
      element=doc.createElement("String_Node_Str");
      racePreferences.appendChild(element);
      race=doc.createAttribute("String_Node_Str");
      race.setValue(r.toString());
      element.setAttributeNode(race);
      preference=doc.createAttribute("String_Node_Str");
      preference.setValue(raceMasculinePreferencesMap.get(r).toString());
      element.setAttributeNode(preference);
    }
    Element itemsDiscovered=doc.createElement("String_Node_Str");
    properties.appendChild(itemsDiscovered);
    for (    AbstractItemType itemType : this.itemsDiscovered) {
      Element element=doc.createElement("String_Node_Str");
      itemsDiscovered.appendChild(element);
      Attr hash=doc.createAttribute("String_Node_Str");
      hash.setValue(itemType.getId());
      element.setAttributeNode(hash);
    }
    Element weaponsDiscovered=doc.createElement("String_Node_Str");
    properties.appendChild(weaponsDiscovered);
    for (    AbstractWeaponType weaponType : this.weaponsDiscovered) {
      Element element=doc.createElement("String_Node_Str");
      weaponsDiscovered.appendChild(element);
      Attr hash=doc.createAttribute("String_Node_Str");
      hash.setValue(weaponType.getId());
      element.setAttributeNode(hash);
    }
    Element clothingDiscovered=doc.createElement("String_Node_Str");
    properties.appendChild(clothingDiscovered);
    for (    AbstractClothingType clothingType : this.clothingDiscovered) {
      Element element=doc.createElement("String_Node_Str");
      clothingDiscovered.appendChild(element);
      Attr hash=doc.createAttribute("String_Node_Str");
      if (clothingType != null)       hash.setValue(clothingType.getId());
      element.setAttributeNode(hash);
    }
    Element racesDiscovered=doc.createElement("String_Node_Str");
    properties.appendChild(racesDiscovered);
    for (    Race race : Race.values()) {
      Element element=doc.createElement("String_Node_Str");
      racesDiscovered.appendChild(element);
      Attr discovered=doc.createAttribute("String_Node_Str");
      discovered.setValue(race.toString());
      element.setAttributeNode(discovered);
      discovered=doc.createAttribute("String_Node_Str");
      discovered.setValue(String.valueOf(this.racesDiscovered.contains(race)));
      element.setAttributeNode(discovered);
      discovered=doc.createAttribute("String_Node_Str");
      discovered.setValue(String.valueOf(this.racesAdvancedKnowledge.contains(race)));
      element.setAttributeNode(discovered);
    }
    TransformerFactory transformerFactory=TransformerFactory.newInstance();
    Transformer transformer=transformerFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT,"String_Node_Str");
    transformer.setOutputProperty("String_Node_Str","String_Node_Str");
    DOMSource source=new DOMSource(doc);
    StreamResult result=new StreamResult(new File("String_Node_Str"));
    transformer.transform(source,result);
  }
 catch (  ParserConfigurationException|TransformerException e) {
    e.printStackTrace();
  }
}