Program: 50949
Project: 50949
Buggy source:
/** 
 * @param profileId
 * @param activationbyDefault
 * @param defaultGoal
 * @param plugin
 * @param androidProfile
 * @param execution
 * @param goalElement
 * @param additionalConfig
 * @param finalName
 * @throws JAXBException
 * @throws PhrescoPomException
 * @throws ParserConfigurationException
 */
public void setProfile(String profileId,Boolean activationbyDefault,String defaultGoal,Plugin plugin,AndroidProfile androidProfile,PluginExecution execution,Element goalElement,List<Element> additionalConfig) throws JAXBException, PhrescoPomException, ParserConfigurationException {
  BuildBase base=new BuildBase();
  Plugins plugins=new Plugins();
  Executions executions=new Executions();
  Goals goals=new Goals();
  Activation activation=new Activation();
  removeProfile(profileId);
  DocumentBuilderFactory dbfac=DocumentBuilderFactory.newInstance();
  DocumentBuilder docBuilder=dbfac.newDocumentBuilder();
  Document doc=docBuilder.newDocument();
  Element element=doc.createElement(PomConstants.KEYSTORE);
  element.setTextContent(androidProfile.getKeystore());
  additionalConfig.add(element);
  element=doc.createElement(PomConstants.STOREPASS);
  element.setTextContent(androidProfile.getStorepass());
  additionalConfig.add(element);
  element=doc.createElement(PomConstants.KEYPASS);
  element.setTextContent(androidProfile.getKeypass());
  additionalConfig.add(element);
  element=doc.createElement(PomConstants.ALIAS);
  element.setTextContent(androidProfile.getAlias());
  additionalConfig.add(element);
  if (androidProfile.getKeystore() != null && androidProfile.getKeypass() != null && androidProfile.getStorepass() != null) {
    base.setDefaultGoal(defaultGoal);
    base.setFinalName(PomConstants.FINAL_NAME);
    activation.setActiveByDefault(activationbyDefault);
    plugin.setExecutions(executions);
    plugin.setGoals(goals);
    plugin.getGoals().getAny().add(goalElement);
    if (plugin.getGoals().getAny().isEmpty()) {
      plugin.setGoals(null);
    }
    execution.getConfiguration().getAny().addAll(additionalConfig);
    plugin.getExecutions().getExecution().add(execution);
    plugins.getPlugin().add(plugin);
    base.setPlugins(plugins);
    addProfile(profileId,activation,base,null);
    save();
  }
 else {
    throw new PhrescoPomException(POMErrorCode.KEYSTORE_NOT_FOUND);
  }
}

Fixed version (ground truth):
/** 
 * @param profileId
 * @param defaultGoal
 * @param plugin
 * @param androidProfile
 * @param execution
 * @param goalElement
 * @param additionalConfig
 * @param finalName
 * @throws JAXBException
 * @throws PhrescoPomException
 * @throws ParserConfigurationException
 */
public void setProfile(String profileId,String defaultGoal,Plugin plugin,AndroidProfile androidProfile,PluginExecution execution,Element goalElement,List<Element> additionalConfig) throws JAXBException, PhrescoPomException, ParserConfigurationException {
  BuildBase base=new BuildBase();
  Plugins plugins=new Plugins();
  Executions executions=new Executions();
  Goals goals=new Goals();
  removeProfile(profileId);
  DocumentBuilderFactory dbfac=DocumentBuilderFactory.newInstance();
  DocumentBuilder docBuilder=dbfac.newDocumentBuilder();
  Document doc=docBuilder.newDocument();
  Element element=doc.createElement(PomConstants.KEYSTORE);
  element.setTextContent(androidProfile.getKeystore());
  additionalConfig.add(element);
  element=doc.createElement(PomConstants.STOREPASS);
  element.setTextContent(androidProfile.getStorepass());
  additionalConfig.add(element);
  element=doc.createElement(PomConstants.KEYPASS);
  element.setTextContent(androidProfile.getKeypass());
  additionalConfig.add(element);
  element=doc.createElement(PomConstants.ALIAS);
  element.setTextContent(androidProfile.getAlias());
  additionalConfig.add(element);
  if (androidProfile.getKeystore() != null && androidProfile.getKeypass() != null && androidProfile.getStorepass() != null) {
    base.setDefaultGoal(defaultGoal);
    base.setFinalName(PomConstants.FINAL_NAME);
    plugin.setExecutions(executions);
    plugin.setGoals(goals);
    plugin.getGoals().getAny().add(goalElement);
    if (plugin.getGoals().getAny().isEmpty()) {
      plugin.setGoals(null);
    }
    execution.getConfiguration().getAny().addAll(additionalConfig);
    plugin.getExecutions().getExecution().add(execution);
    plugins.getPlugin().add(plugin);
    base.setPlugins(plugins);
    addProfile(profileId,base,null);
    save();
  }
 else {
    throw new PhrescoPomException(POMErrorCode.KEYSTORE_NOT_FOUND);
  }
}