Program: 48469
Project: 48469
Buggy source:
public CmClusterDef(ClusterBlueprint blueprint) throws IOException {
  this.name=blueprint.getName();
  this.displayName=blueprint.getName();
  try {
    String[] distroInfo=blueprint.getHadoopStack().getDistro().split("String_Node_Str");
    this.version=distroInfo[0] + (new DefaultArtifactVersion(distroInfo[1])).getMajorVersion();
    this.fullVersion=distroInfo[1];
  }
 catch (  Exception e) {
    this.version=ApiClusterVersion.CDH5.toString();
    this.fullVersion=null;
  }
  this.nodes=new ArrayList<CmNodeDef>();
  this.services=new ArrayList<CmServiceDef>();
  this.currentReport=new ClusterReport(blueprint);
  this.failoverEnabled=isFailoverEnabled(blueprint);
  Integer zkIdIndex=1;
  Integer nameServiceIndex=0;
  boolean hasImpala=false;
  for (  NodeGroupInfo group : blueprint.getNodeGroups()) {
    boolean alreadyHasActive=false;
    for (    NodeInfo node : group.getNodes()) {
      CmNodeDef nodeDef=new CmNodeDef();
      nodeDef.setIpAddress(node.getMgtIpAddress());
      nodeDef.setFqdn(node.getMgtIpAddress());
      nodeDef.setName(node.getName());
      nodeDef.setRackId(node.getRack());
      nodeDef.setNodeId(node.getName());
      nodeDef.setConfigs(null);
      this.nodes.add(nodeDef);
      for (      String type : group.getRoles()) {
        AvailableServiceRole roleType=AvailableServiceRoleContainer.load(type);
        AvailableServiceRole serviceType=roleType.getParent();
        if (serviceType.getDisplayName().equals("String_Node_Str")) {
          hasImpala=true;
        }
        CmServiceDef service=serviceDefOfType(serviceType,blueprint.getConfiguration());
        CmRoleDef roleDef=new CmRoleDef();
        roleDef.setName(node.getName() + NAME_SEPARATOR + service.getType().getName()+ NAME_SEPARATOR+ roleType.getName());
        roleDef.setDisplayName(roleDef.getName());
        roleDef.setType(roleType);
        roleDef.setNodeRef(nodeDef.getNodeId());
switch (roleType.getDisplayName()) {
case "String_Node_Str":
          roleDef.addConfig(Constants.CONFIG_DFS_NAME_DIR_LIST,dataDirs(node.getVolumes(),"String_Node_Str"));
        if (failoverEnabled) {
          if (!alreadyHasActive) {
            nameServiceIndex++;
          }
          roleDef.addConfig(Constants.CONFIG_AUTO_FAILOVER_ENABLED,"String_Node_Str");
          roleDef.addConfig(Constants.CONFIG_DFS_FEDERATION_NAMESERVICE,"String_Node_Str" + nameServiceIndex.toString());
          roleDef.addConfig(Constants.CONFIG_DFS_NAMENODE_QUORUM_JOURNAL_NAME,"String_Node_Str" + nameServiceIndex.toString());
          roleDef.setActive(!alreadyHasActive);
          if (!group.getRoles().contains("String_Node_Str")) {
            CmRoleDef failoverRole=new CmRoleDef();
            AvailableServiceRole failoverRoleType=AvailableServiceRoleContainer.load("String_Node_Str");
            failoverRole.setName(node.getName() + NAME_SEPARATOR + service.getType().getName()+ NAME_SEPARATOR+ failoverRoleType.getName());
            failoverRole.setType(failoverRoleType);
            failoverRole.setNodeRef(nodeDef.getNodeId());
            failoverRole.addConfigs(blueprint.getConfiguration());
            failoverRole.addConfigs(group.getConfiguration());
            failoverRole.setActive(!alreadyHasActive);
            service.addRole(failoverRole);
          }
          alreadyHasActive=true;
        }
      break;
case "String_Node_Str":
    roleDef.setActive(!alreadyHasActive);
  break;
case "String_Node_Str":
roleDef.addConfig(Constants.CONFIG_DFS_DATA_DIR_LIST,dataDirs(node.getVolumes(),"String_Node_Str"));
break;
case "String_Node_Str":
roleDef.addConfig(Constants.CONFIG_DFS_JOURNALNODE_EDITS_DIR,node.getVolumes().get(0) + "String_Node_Str");
break;
case "String_Node_Str":
roleDef.addConfig(Constants.CONFIG_FS_CHECKPOINT_DIR_LIST,dataDirs(node.getVolumes(),"String_Node_Str"));
break;
case "String_Node_Str":
roleDef.addConfig(Constants.CONFIG_NM_LOCAL_DIRS,dataDirs(node.getVolumes(),"String_Node_Str"));
break;
case "String_Node_Str":
roleDef.addConfig(Constants.CONFIG_MAPRED_JT_LOCAL_DIR_LIST,dataDirs(node.getVolumes(),"String_Node_Str"));
break;
case "String_Node_Str":
roleDef.addConfig(Constants.CONFIG_MAPRED_TT_LOCAL_DIR_LIST,dataDirs(node.getVolumes(),"String_Node_Str"));
break;
case "String_Node_Str":
roleDef.addConfig(Constants.CONFIG_ZOOKEEPER_SERVER_ID,zkIdIndex.toString());
zkIdIndex+=1;
break;
case "String_Node_Str":
roleDef.addConfig(Constants.CONFIG_SQOOP_METASTORE_DATA_DIR,node.getVolumes().get(0) + "String_Node_Str");
break;
default :
break;
}
roleDef.addConfigs(blueprint.getConfiguration());
roleDef.addConfigs(group.getConfiguration());
service.addRole(roleDef);
}
}
if (hasImpala) {
for (CmServiceDef serviceDef : services) {
if (serviceDef.getType().getDisplayName().equals("String_Node_Str")) {
serviceDef.addConfig("String_Node_Str","String_Node_Str");
for (CmRoleDef roleDef : serviceDef.getRoles()) {
if (roleDef.getType().getDisplayName().equals("String_Node_Str")) {
roleDef.addConfig("String_Node_Str","String_Node_Str");
}
}
break;
}
}
}
}
}

Fixed version (ground truth):
public CmClusterDef(ClusterBlueprint blueprint) throws IOException {
  this.name=blueprint.getName();
  this.displayName=blueprint.getName();
  try {
    String[] distroInfo=blueprint.getHadoopStack().getDistro().split("String_Node_Str");
    this.version=distroInfo[0] + (new DefaultArtifactVersion(distroInfo[1])).getMajorVersion();
    this.fullVersion=distroInfo[1];
  }
 catch (  Exception e) {
    this.version=ApiClusterVersion.CDH5.toString();
    this.fullVersion=null;
  }
  this.nodes=new ArrayList<CmNodeDef>();
  this.services=new ArrayList<CmServiceDef>();
  this.currentReport=new ClusterReport(blueprint);
  this.failoverEnabled=isFailoverEnabled(blueprint);
  Integer zkIdIndex=1;
  Integer nameServiceIndex=0;
  boolean hasImpala=false;
  for (  NodeGroupInfo group : blueprint.getNodeGroups()) {
    boolean alreadyHasActive=false;
    for (    NodeInfo node : group.getNodes()) {
      CmNodeDef nodeDef=new CmNodeDef();
      nodeDef.setIpAddress(node.getMgtIpAddress());
      nodeDef.setFqdn(node.getMgtIpAddress());
      nodeDef.setName(node.getName());
      nodeDef.setRackId(node.getRack());
      nodeDef.setNodeId(node.getName());
      nodeDef.setConfigs(null);
      this.nodes.add(nodeDef);
      for (      String type : group.getRoles()) {
        AvailableServiceRole roleType=AvailableServiceRoleContainer.load(type);
        AvailableServiceRole serviceType=roleType.getParent();
        if (serviceType.getDisplayName().equals("String_Node_Str")) {
          hasImpala=true;
        }
        CmServiceDef service=serviceDefOfType(serviceType,blueprint.getConfiguration());
        CmRoleDef roleDef=new CmRoleDef();
        roleDef.setName(node.getName() + NAME_SEPARATOR + service.getType().getName()+ NAME_SEPARATOR+ roleType.getName());
        roleDef.setDisplayName(roleDef.getName());
        roleDef.setType(roleType);
        roleDef.setNodeRef(nodeDef.getNodeId());
switch (roleType.getDisplayName()) {
case "String_Node_Str":
          roleDef.addConfig(Constants.CONFIG_DFS_NAME_DIR_LIST,dataDirs(node.getVolumes(),"String_Node_Str"));
        if (failoverEnabled) {
          if (!alreadyHasActive) {
            nameServiceIndex++;
          }
          roleDef.addConfig(Constants.CONFIG_AUTO_FAILOVER_ENABLED,"String_Node_Str");
          roleDef.addConfig(Constants.CONFIG_DFS_FEDERATION_NAMESERVICE,"String_Node_Str" + nameServiceIndex.toString());
          roleDef.addConfig(Constants.CONFIG_DFS_NAMENODE_QUORUM_JOURNAL_NAME,"String_Node_Str" + nameServiceIndex.toString());
          roleDef.setActive(!alreadyHasActive);
          if (!group.getRoles().contains("String_Node_Str")) {
            CmRoleDef failoverRole=new CmRoleDef();
            AvailableServiceRole failoverRoleType=AvailableServiceRoleContainer.load("String_Node_Str");
            failoverRole.setName(node.getName() + NAME_SEPARATOR + service.getType().getName()+ NAME_SEPARATOR+ failoverRoleType.getName());
            failoverRole.setType(failoverRoleType);
            failoverRole.setNodeRef(nodeDef.getNodeId());
            failoverRole.addConfigs(blueprint.getConfiguration());
            failoverRole.addConfigs(group.getConfiguration());
            failoverRole.setActive(!alreadyHasActive);
            service.addRole(failoverRole);
          }
          alreadyHasActive=true;
        }
      break;
case "String_Node_Str":
    roleDef.setActive(!alreadyHasActive);
  break;
case "String_Node_Str":
roleDef.addConfig(Constants.CONFIG_DFS_DATA_DIR_LIST,dataDirs(node.getVolumes(),"String_Node_Str"));
break;
case "String_Node_Str":
if (!node.getVolumes().isEmpty()) {
roleDef.addConfig(Constants.CONFIG_DFS_JOURNALNODE_EDITS_DIR,node.getVolumes().get(0) + "String_Node_Str");
}
 else {
logger.warn("String_Node_Str" + node.getName());
}
break;
case "String_Node_Str":
roleDef.addConfig(Constants.CONFIG_FS_CHECKPOINT_DIR_LIST,dataDirs(node.getVolumes(),"String_Node_Str"));
break;
case "String_Node_Str":
roleDef.addConfig(Constants.CONFIG_NM_LOCAL_DIRS,dataDirs(node.getVolumes(),"String_Node_Str"));
break;
case "String_Node_Str":
roleDef.addConfig(Constants.CONFIG_MAPRED_JT_LOCAL_DIR_LIST,dataDirs(node.getVolumes(),"String_Node_Str"));
break;
case "String_Node_Str":
roleDef.addConfig(Constants.CONFIG_MAPRED_TT_LOCAL_DIR_LIST,dataDirs(node.getVolumes(),"String_Node_Str"));
break;
case "String_Node_Str":
roleDef.addConfig(Constants.CONFIG_ZOOKEEPER_SERVER_ID,zkIdIndex.toString());
zkIdIndex+=1;
break;
case "String_Node_Str":
roleDef.addConfig(Constants.CONFIG_SQOOP_METASTORE_DATA_DIR,node.getVolumes().get(0) + "String_Node_Str");
break;
default :
break;
}
roleDef.addConfigs(blueprint.getConfiguration());
roleDef.addConfigs(group.getConfiguration());
service.addRole(roleDef);
}
}
if (hasImpala) {
for (CmServiceDef serviceDef : services) {
if (serviceDef.getType().getDisplayName().equals("String_Node_Str")) {
serviceDef.addConfig("String_Node_Str","String_Node_Str");
for (CmRoleDef roleDef : serviceDef.getRoles()) {
if (roleDef.getType().getDisplayName().equals("String_Node_Str")) {
roleDef.addConfig("String_Node_Str","String_Node_Str");
}
}
break;
}
}
}
}
}