Program: 48515
Project: 48515
Buggy source:
/** 
 * Create default cluster spec.
 * @param type cluster type
 * @return default cluster spec
 * @throws FileNotFoundException
 */
public static ClusterCreate createDefaultSpec(ClusterType type,String vendor,String distroVersion,String appManagerType) throws FileNotFoundException {
  if (vendor.trim().equalsIgnoreCase(Constants.MAPR_VENDOR)) {
switch (type) {
case HDFS_MAPRED:
      return loadFromFile(locateSpecFile(HDFS_MAPRED_MAPR_TEMPLATE_SPEC));
case HDFS_HBASE:
    return loadFromFile(locateSpecFile(HDFS_HBASE_MAPR_TEMPLATE_SPEC));
default :
  throw BddException.INVALID_PARAMETER("String_Node_Str",type);
}
}
 else if (vendor.trim().equalsIgnoreCase(Constants.GPHD_VENDOR)) {
switch (type) {
case HDFS:
return loadFromFile(locateSpecFile(HDFS_GPHD_TEMPLATE_SPEC));
case HDFS_MAPRED:
return loadFromFile(locateSpecFile(HDFS_MAPRED_GPHD_TEMPLATE_SPEC));
case HDFS_HBASE:
return loadFromFile(locateSpecFile(HDFS_HBASE_GPHD_TEMPLATE_SPEC));
default :
throw BddException.INVALID_PARAMETER("String_Node_Str",type);
}
}
 else if (Constants.AMBARI_PLUGIN_TYPE.equals(appManagerType) && vendor.trim().equalsIgnoreCase(Constants.HDP_VENDOR)) {
MAPREDUCE_VERSION mr=getDefaultMapReduceVersion(vendor,distroVersion);
if (type == null) {
if (mr == MAPREDUCE_VERSION.V1) {
return loadFromFile(locateSpecFile(AM_HDFS_MAPRED_TEMPLATE_SPEC));
}
 else {
return loadFromFile(locateSpecFile(AM_HDFS_YARN_TEMPLATE_SPEC));
}
}
HDFS_VERSION hdfs=getDefaultHdfsVersion(vendor,distroVersion);
switch (type) {
case HDFS:
if (hdfs == HDFS_VERSION.V1) {
return loadFromFile(locateSpecFile(AM_HDFS_V1_TEMPLATE_SPEC));
}
 else {
return loadFromFile(locateSpecFile(AM_HDFS_V2_TEMPLATE_SPEC));
}
case HDFS_MAPRED:
if (mr == MAPREDUCE_VERSION.V1) {
return loadFromFile(locateSpecFile(AM_HDFS_MAPRED_TEMPLATE_SPEC));
}
 else {
return loadFromFile(locateSpecFile(AM_HDFS_YARN_TEMPLATE_SPEC));
}
case HDFS_HBASE:
if (Configuration.getBoolean(Constants.AMBARI_HBASE_DEPEND_ON_MAPREDUCE)) {
if (hdfs == HDFS_VERSION.V1) {
return loadFromFile(locateSpecFile(AM_HDFS_V1_HBASE_TEMPLATE_SPEC));
}
 else {
return loadFromFile(locateSpecFile(AM_HDFS_V2_HBASE_TEMPLATE_SPEC));
}
}
 else {
return loadFromFile(locateSpecFile(AM_HDFS_PURE_HBASE_TEMPLATE_SPEC));
}
default :
throw BddException.INVALID_PARAMETER("String_Node_Str",type);
}
}
 else {
MAPREDUCE_VERSION mr=getDefaultMapReduceVersion(vendor,distroVersion);
if (Constants.CLOUDERA_MANAGER_PLUGIN_TYPE.equals(appManagerType)) {
if (mr == MAPREDUCE_VERSION.V1) {
return loadFromFile(locateSpecFile(CM_HDFS_MAPRED_TEMPLATE_SPEC));
}
 else {
return loadFromFile(locateSpecFile(CM_HDFS_YARN_TEMPLATE_SPEC));
}
}
switch (type) {
case HDFS:
return loadFromFile(locateSpecFile(HDFS_TEMPLATE_SPEC));
case HDFS_MAPRED:
if (mr == MAPREDUCE_VERSION.V1) {
return loadFromFile(locateSpecFile(HDFS_MAPRED_TEMPLATE_SPEC));
}
 else {
return loadFromFile(locateSpecFile(HDFS_YARN_TEMPLATE_SPEC));
}
case HDFS_HBASE:
return loadFromFile(locateSpecFile(HDFS_HBASE_TEMPLATE_SPEC));
default :
throw BddException.INVALID_PARAMETER("String_Node_Str",type);
}
}
}

Fixed version (ground truth):
/** 
 * Create default cluster spec.
 * @param type cluster type
 * @return default cluster spec
 * @throws FileNotFoundException
 */
public static ClusterCreate createDefaultSpec(ClusterType type,String vendor,String distroVersion,String appManagerType) throws FileNotFoundException {
  if (vendor.trim().equalsIgnoreCase(Constants.MAPR_VENDOR)) {
switch (type) {
case HDFS_MAPRED:
      return loadFromFile(locateSpecFile(HDFS_MAPRED_MAPR_TEMPLATE_SPEC));
case HDFS_HBASE:
    return loadFromFile(locateSpecFile(HDFS_HBASE_MAPR_TEMPLATE_SPEC));
default :
  throw BddException.INVALID_PARAMETER("String_Node_Str",type);
}
}
 else if (vendor.trim().equalsIgnoreCase(Constants.GPHD_VENDOR)) {
switch (type) {
case HDFS:
return loadFromFile(locateSpecFile(HDFS_GPHD_TEMPLATE_SPEC));
case HDFS_MAPRED:
return loadFromFile(locateSpecFile(HDFS_MAPRED_GPHD_TEMPLATE_SPEC));
case HDFS_HBASE:
return loadFromFile(locateSpecFile(HDFS_HBASE_GPHD_TEMPLATE_SPEC));
default :
throw BddException.INVALID_PARAMETER("String_Node_Str",type);
}
}
 else if (Constants.AMBARI_PLUGIN_TYPE.equals(appManagerType) && vendor.trim().equalsIgnoreCase(Constants.HDP_VENDOR)) {
MAPREDUCE_VERSION mr=getDefaultMapReduceVersion(vendor,distroVersion);
HDP_VERSION hdpVersion=getDefaultHdfsVersion(vendor,distroVersion);
if (type == null) {
if (mr == MAPREDUCE_VERSION.V1) {
return loadFromFile(locateSpecFile(AM_HDFS_MAPRED_TEMPLATE_SPEC));
}
 else {
if (hdpVersion == HDP_VERSION.V2_0) {
return loadFromFile(locateSpecFile(AM_HDP_2_0_HDFS_YARN_TEMPLATE_SPEC));
}
 else {
return loadFromFile(locateSpecFile(AM_HDP_2_1_HDFS_YARN_TEMPLATE_SPEC));
}
}
}
switch (type) {
case HDFS:
if (hdpVersion == HDP_VERSION.V1) {
return loadFromFile(locateSpecFile(AM_HDFS_V1_TEMPLATE_SPEC));
}
 else {
return loadFromFile(locateSpecFile(AM_HDFS_V2_TEMPLATE_SPEC));
}
case HDFS_MAPRED:
if (mr == MAPREDUCE_VERSION.V1) {
return loadFromFile(locateSpecFile(AM_HDFS_MAPRED_TEMPLATE_SPEC));
}
 else {
if (hdpVersion == HDP_VERSION.V2_0) {
return loadFromFile(locateSpecFile(AM_HDP_2_0_HDFS_YARN_TEMPLATE_SPEC));
}
 else {
return loadFromFile(locateSpecFile(AM_HDP_2_1_HDFS_YARN_TEMPLATE_SPEC));
}
}
case HDFS_HBASE:
if (Configuration.getBoolean(Constants.AMBARI_HBASE_DEPEND_ON_MAPREDUCE)) {
if (hdpVersion == HDP_VERSION.V1) {
return loadFromFile(locateSpecFile(AM_HDFS_V1_HBASE_TEMPLATE_SPEC));
}
 else {
return loadFromFile(locateSpecFile(AM_HDFS_V2_HBASE_TEMPLATE_SPEC));
}
}
 else {
return loadFromFile(locateSpecFile(AM_HDFS_PURE_HBASE_TEMPLATE_SPEC));
}
default :
throw BddException.INVALID_PARAMETER("String_Node_Str",type);
}
}
 else {
MAPREDUCE_VERSION mr=getDefaultMapReduceVersion(vendor,distroVersion);
if (Constants.CLOUDERA_MANAGER_PLUGIN_TYPE.equals(appManagerType)) {
if (mr == MAPREDUCE_VERSION.V1) {
return loadFromFile(locateSpecFile(CM_HDFS_MAPRED_TEMPLATE_SPEC));
}
 else {
return loadFromFile(locateSpecFile(CM_HDFS_YARN_TEMPLATE_SPEC));
}
}
switch (type) {
case HDFS:
return loadFromFile(locateSpecFile(HDFS_TEMPLATE_SPEC));
case HDFS_MAPRED:
if (mr == MAPREDUCE_VERSION.V1) {
return loadFromFile(locateSpecFile(HDFS_MAPRED_TEMPLATE_SPEC));
}
 else {
return loadFromFile(locateSpecFile(HDFS_YARN_TEMPLATE_SPEC));
}
case HDFS_HBASE:
return loadFromFile(locateSpecFile(HDFS_HBASE_TEMPLATE_SPEC));
default :
throw BddException.INVALID_PARAMETER("String_Node_Str",type);
}
}
}