Program: 48268
Project: 48268
Buggy source:
public AmClusterDef(ClusterBlueprint blueprint,String privateKey,String ambariServerVersion){
  this.name=blueprint.getName();
  this.version=blueprint.getHadoopStack().getFullVersion();
  this.verbose=true;
  this.sshKey=privateKey;
  this.user=Constants.AMBARI_SSH_USER;
  this.currentReport=new ClusterReport(blueprint);
  this.ambariServerVersion=ambariServerVersion;
  this.rackTopology=blueprint.getRackTopology();
  HdfsVersion hdfs=getDefaultHdfsVersion(this.version);
  if (blueprint.hasTopologyPolicy() && !AmUtils.isAmbariServerGreaterOrEquals_2_1_0(ambariServerVersion)) {
    setRackTopologyFileName(blueprint);
  }
  setAdditionalConfigurations(blueprint,ambariServerVersion);
  this.configurations=AmUtils.toAmConfigurations(blueprint.getConfiguration());
  this.nodeGroups=new ArrayList<AmNodeGroupDef>();
  for (  NodeGroupInfo group : blueprint.getNodeGroups()) {
    AmNodeGroupDef nodeGroupDef=new AmNodeGroupDef();
    nodeGroupDef.setName(group.getName());
    nodeGroupDef.setInstanceNum(group.getInstanceNum());
    nodeGroupDef.setRoles(group.getRoles());
    nodeGroupDef.setConfigurations(AmUtils.toAmConfigurations(group.getConfiguration()));
    nodeGroupDef.setClusterName(this.name);
    nodeGroupDef.setAmbariServerVersion(ambariServerVersion);
    List<AmNodeDef> nodes=new ArrayList<AmNodeDef>();
    for (    NodeInfo node : group.getNodes()) {
      AmNodeDef nodeDef=new AmNodeDef();
      nodeDef.setName(node.getName());
      nodeDef.setIp(node.getMgtIpAddress());
      nodeDef.setFqdn(node.getHostname());
      nodeDef.setRackInfo(node.getRack());
      nodeDef.setConfigurations(AmUtils.toAmConfigurations(group.getConfiguration()));
      nodeDef.setComponents(group.getRoles());
      nodeDef.setVolumes(node.getVolumes());
      nodeDef.setDirsConfig(hdfs,ambariServerVersion);
      nodes.add(nodeDef);
    }
    nodeGroupDef.setNodes(nodes);
    this.nodeGroups.add(nodeGroupDef);
  }
  if (blueprint.getExternalNamenode() != null) {
    this.isComputeOnly=true;
    this.externalNamenode=blueprint.getExternalNamenode();
    this.externalSecondaryNamenode=blueprint.getExternalSecondaryNamenode();
    String externalNameNodeGroupName="String_Node_Str";
    AmNodeDef namenodeDef=new AmNodeDef();
    namenodeDef.setName(name + "String_Node_Str" + externalNameNodeGroupName+ "String_Node_Str");
    namenodeDef.setFqdn(externalNamenode);
    List<String> namenodeRoles=new ArrayList<String>();
    namenodeRoles.add("String_Node_Str");
    if (!isValidExternalSecondaryNamenode()) {
      namenodeRoles.add("String_Node_Str");
    }
    namenodeDef.setComponents(namenodeRoles);
    namenodeDef.setVolumes(new ArrayList<String>());
    namenodeDef.setConfigurations(AmUtils.toAmConfigurations(null));
    AmNodeGroupDef externalNameNodeGroup=new AmNodeGroupDef();
    externalNameNodeGroup.setName(externalNameNodeGroupName);
    externalNameNodeGroup.setConfigurations(AmUtils.toAmConfigurations(null));
    externalNameNodeGroup.setRoles(namenodeRoles);
    externalNameNodeGroup.setInstanceNum(1);
    externalNameNodeGroup.setAmbariServerVersion(ambariServerVersion);
    List<AmNodeDef> externalNameNodes=new ArrayList<AmNodeDef>();
    externalNameNodes.add(namenodeDef);
    externalNameNodeGroup.setNodes(externalNameNodes);
    this.nodeGroups.add(externalNameNodeGroup);
    if (isValidExternalSecondaryNamenode()) {
      String externalSecondaryNameNodeGroupName="String_Node_Str";
      AmNodeDef secondaryNamenodeDef=new AmNodeDef();
      secondaryNamenodeDef.setName(name + "String_Node_Str" + externalSecondaryNameNodeGroupName+ "String_Node_Str");
      secondaryNamenodeDef.setFqdn(externalSecondaryNamenode);
      List<String> secondaryNamenodeRoles=new ArrayList<String>();
      secondaryNamenodeRoles.add("String_Node_Str");
      secondaryNamenodeDef.setComponents(secondaryNamenodeRoles);
      secondaryNamenodeDef.setVolumes(new ArrayList<String>());
      secondaryNamenodeDef.setConfigurations(AmUtils.toAmConfigurations(null));
      AmNodeGroupDef externalSecondaryNameNodeGroup=new AmNodeGroupDef();
      externalSecondaryNameNodeGroup.setName(externalSecondaryNameNodeGroupName);
      externalSecondaryNameNodeGroup.setConfigurations(AmUtils.toAmConfigurations(null));
      externalSecondaryNameNodeGroup.setRoles(secondaryNamenodeRoles);
      externalSecondaryNameNodeGroup.setInstanceNum(1);
      List<AmNodeDef> externalSecondaryNameNodes=new ArrayList<AmNodeDef>();
      externalSecondaryNameNodes.add(secondaryNamenodeDef);
      externalSecondaryNameNodeGroup.setNodes(externalSecondaryNameNodes);
      this.nodeGroups.add(externalSecondaryNameNodeGroup);
    }
  }
  AmStackDef stackDef=new AmStackDef();
  stackDef.setName(blueprint.getHadoopStack().getVendor());
  stackDef.setVersion(blueprint.getHadoopStack().getFullVersion());
  this.amStack=stackDef;
}

Fixed version (ground truth):
public AmClusterDef(ClusterBlueprint blueprint,String privateKey,String ambariServerVersion){
  this.name=blueprint.getName();
  this.version=blueprint.getHadoopStack().getFullVersion();
  this.verbose=true;
  this.sshKey=privateKey;
  this.user=Constants.AMBARI_SSH_USER;
  this.currentReport=new ClusterReport(blueprint);
  this.ambariServerVersion=ambariServerVersion;
  this.rackTopology=blueprint.getRackTopology();
  HdfsVersion hdfs=getDefaultHdfsVersion(this.version);
  if (blueprint.hasTopologyPolicy() && !AmUtils.isAmbariServerGreaterOrEquals_2_1_0(ambariServerVersion)) {
    setRackTopologyFileName(blueprint);
  }
  setAdditionalConfigurations(blueprint,ambariServerVersion);
  this.configurations=AmUtils.toAmConfigurations(blueprint.getConfiguration());
  this.nodeGroups=new ArrayList<AmNodeGroupDef>();
  for (  NodeGroupInfo group : blueprint.getNodeGroups()) {
    AmNodeGroupDef nodeGroupDef=new AmNodeGroupDef();
    nodeGroupDef.setName(group.getName());
    nodeGroupDef.setInstanceNum(group.getInstanceNum());
    nodeGroupDef.setRoles(group.getRoles());
    nodeGroupDef.setConfigurations(AmUtils.toAmConfigurations(group.getConfiguration()));
    nodeGroupDef.setClusterName(this.name);
    nodeGroupDef.setAmbariServerVersion(ambariServerVersion);
    List<AmNodeDef> nodes=new ArrayList<AmNodeDef>();
    for (    NodeInfo node : group.getNodes()) {
      AmNodeDef nodeDef=new AmNodeDef();
      nodeDef.setName(node.getName());
      nodeDef.setIp(node.getMgtIpAddress());
      nodeDef.setFqdn(node.getMgtFqdn());
      nodeDef.setRackInfo(node.getRack());
      nodeDef.setConfigurations(AmUtils.toAmConfigurations(group.getConfiguration()));
      nodeDef.setComponents(group.getRoles());
      nodeDef.setVolumes(node.getVolumes());
      nodeDef.setDirsConfig(hdfs,ambariServerVersion);
      nodes.add(nodeDef);
    }
    nodeGroupDef.setNodes(nodes);
    this.nodeGroups.add(nodeGroupDef);
  }
  if (blueprint.getExternalNamenode() != null) {
    this.isComputeOnly=true;
    this.externalNamenode=blueprint.getExternalNamenode();
    this.externalSecondaryNamenode=blueprint.getExternalSecondaryNamenode();
    String externalNameNodeGroupName="String_Node_Str";
    AmNodeDef namenodeDef=new AmNodeDef();
    namenodeDef.setName(name + "String_Node_Str" + externalNameNodeGroupName+ "String_Node_Str");
    namenodeDef.setFqdn(externalNamenode);
    List<String> namenodeRoles=new ArrayList<String>();
    namenodeRoles.add("String_Node_Str");
    if (!isValidExternalSecondaryNamenode()) {
      namenodeRoles.add("String_Node_Str");
    }
    namenodeDef.setComponents(namenodeRoles);
    namenodeDef.setVolumes(new ArrayList<String>());
    namenodeDef.setConfigurations(AmUtils.toAmConfigurations(null));
    AmNodeGroupDef externalNameNodeGroup=new AmNodeGroupDef();
    externalNameNodeGroup.setName(externalNameNodeGroupName);
    externalNameNodeGroup.setConfigurations(AmUtils.toAmConfigurations(null));
    externalNameNodeGroup.setRoles(namenodeRoles);
    externalNameNodeGroup.setInstanceNum(1);
    externalNameNodeGroup.setAmbariServerVersion(ambariServerVersion);
    List<AmNodeDef> externalNameNodes=new ArrayList<AmNodeDef>();
    externalNameNodes.add(namenodeDef);
    externalNameNodeGroup.setNodes(externalNameNodes);
    this.nodeGroups.add(externalNameNodeGroup);
    if (isValidExternalSecondaryNamenode()) {
      String externalSecondaryNameNodeGroupName="String_Node_Str";
      AmNodeDef secondaryNamenodeDef=new AmNodeDef();
      secondaryNamenodeDef.setName(name + "String_Node_Str" + externalSecondaryNameNodeGroupName+ "String_Node_Str");
      secondaryNamenodeDef.setFqdn(externalSecondaryNamenode);
      List<String> secondaryNamenodeRoles=new ArrayList<String>();
      secondaryNamenodeRoles.add("String_Node_Str");
      secondaryNamenodeDef.setComponents(secondaryNamenodeRoles);
      secondaryNamenodeDef.setVolumes(new ArrayList<String>());
      secondaryNamenodeDef.setConfigurations(AmUtils.toAmConfigurations(null));
      AmNodeGroupDef externalSecondaryNameNodeGroup=new AmNodeGroupDef();
      externalSecondaryNameNodeGroup.setName(externalSecondaryNameNodeGroupName);
      externalSecondaryNameNodeGroup.setConfigurations(AmUtils.toAmConfigurations(null));
      externalSecondaryNameNodeGroup.setRoles(secondaryNamenodeRoles);
      externalSecondaryNameNodeGroup.setInstanceNum(1);
      List<AmNodeDef> externalSecondaryNameNodes=new ArrayList<AmNodeDef>();
      externalSecondaryNameNodes.add(secondaryNamenodeDef);
      externalSecondaryNameNodeGroup.setNodes(externalSecondaryNameNodes);
      this.nodeGroups.add(externalSecondaryNameNodeGroup);
    }
  }
  AmStackDef stackDef=new AmStackDef();
  stackDef.setName(blueprint.getHadoopStack().getVendor());
  stackDef.setVersion(blueprint.getHadoopStack().getFullVersion());
  this.amStack=stackDef;
}