Program: 49134
Project: 49134
Buggy source:
private NodeGroupEntity convertGroup(Gson gson,ClusterEntity clusterEntity,EnumSet<HadoopRole> allRoles,NodeGroupCreate group,String distro,boolean validateWhiteList){
  NodeGroupEntity groupEntity=new NodeGroupEntity();
  if (group.getRoles() == null || group.getRoles().isEmpty()) {
    throw ClusterConfigException.NO_HADOOP_ROLE_SPECIFIED(group.getName());
  }
  Set<String> roles=new HashSet<String>();
  roles.addAll(group.getRoles());
  EnumSet<HadoopRole> enumRoles=getEnumRoles(group.getRoles(),distro);
  if (enumRoles.isEmpty()) {
    throw ClusterConfigException.NO_HADOOP_ROLE_SPECIFIED(group.getName());
  }
  groupEntity.setRoles(gson.toJson(roles));
  GroupType groupType=GroupType.fromHadoopRole(enumRoles);
  boolean removeIt=validateGroupInstanceNum(clusterEntity.getName(),groupType,group,allRoles);
  if (removeIt) {
    return null;
  }
  allRoles.addAll(enumRoles);
  groupEntity.setCluster(clusterEntity);
  groupEntity.setCpuNum(group.getCpuNum());
  groupEntity.setDefineInstanceNum(group.getInstanceNum());
  groupEntity.setMemorySize(group.getMemCapacityMB());
  groupEntity.setName(group.getName());
  groupEntity.setNodeType(group.getInstanceType());
  PlacementPolicy policies=group.getPlacementPolicies();
  if (policies != null) {
    List<GroupAssociation> associons=policies.getGroupAssociations();
    if (associons != null) {
      Set<NodeGroupAssociation> associonEntities=new TreeSet<NodeGroupAssociation>();
      for (      GroupAssociation a : associons) {
        NodeGroupAssociation ae=new NodeGroupAssociation();
        ae.setAssociationType(a.getType());
        ae.setNodeGroup(groupEntity);
        ae.setReferencedGroup(a.getReference());
        associonEntities.add(ae);
      }
      groupEntity.setGroupAssociations(associonEntities);
    }
    if (policies.getInstancePerHost() != null) {
      groupEntity.setInstancePerHost(policies.getInstancePerHost());
    }
    if (policies.getGroupRacks() != null) {
      groupEntity.setGroupRacks((new Gson()).toJson(policies.getGroupRacks()));
    }
  }
  if (group.getRpNames() != null && group.getRpNames().size() > 0) {
    groupEntity.setVcRpNameList(group.getRpNames());
  }
  if (group.getStorage() != null) {
    groupEntity.setStorageSize(group.getStorage().getSizeGB());
    if (group.getStorage().getType() != null) {
      if (group.getStorage().getType().equals(DatastoreType.LOCAL.name())) {
        groupEntity.setStorageType(DatastoreType.LOCAL);
      }
 else {
        groupEntity.setStorageType(DatastoreType.SHARED);
      }
    }
    groupEntity.setVcDatastoreNameList(group.getStorage().getDsNames());
  }
  List<String> dsNames=groupEntity.getVcDatastoreNameList();
  if (dsNames == null) {
    dsNames=clusterEntity.getVcDatastoreNameList();
  }
  Set<String> sharedPattern=datastoreMgr.getSharedDatastoresByNames(dsNames);
  Set<String> localPattern=datastoreMgr.getLocalDatastoresByNames(dsNames);
  CommonClusterExpandPolicy.expandGroupInstanceType(groupEntity,groupType,sharedPattern,localPattern);
  groupEntity.setHaFlag(group.getHaFlag());
  if (group.getConfiguration() != null && group.getConfiguration().size() > 0) {
    CommonClusterExpandPolicy.validateAppConfig(group.getConfiguration(),validateWhiteList);
    groupEntity.setHadoopConfig(gson.toJson(group.getConfiguration()));
  }
  logger.debug("String_Node_Str" + group.getName());
  return groupEntity;
}

Fixed version (ground truth):
private NodeGroupEntity convertGroup(Gson gson,ClusterEntity clusterEntity,EnumSet<HadoopRole> allRoles,NodeGroupCreate group,String distro,boolean validateWhiteList){
  NodeGroupEntity groupEntity=new NodeGroupEntity();
  if (group.getRoles() == null || group.getRoles().isEmpty()) {
    throw ClusterConfigException.NO_HADOOP_ROLE_SPECIFIED(group.getName());
  }
  Set<String> roles=new HashSet<String>();
  roles.addAll(group.getRoles());
  EnumSet<HadoopRole> enumRoles=getEnumRoles(group.getRoles(),distro);
  if (enumRoles.isEmpty()) {
    throw ClusterConfigException.NO_HADOOP_ROLE_SPECIFIED(group.getName());
  }
  groupEntity.setRoles(gson.toJson(roles));
  GroupType groupType=GroupType.fromHadoopRole(enumRoles);
  boolean removeIt=validateGroupInstanceNum(clusterEntity.getName(),groupType,group,allRoles);
  if (removeIt) {
    return null;
  }
  allRoles.addAll(enumRoles);
  groupEntity.setCluster(clusterEntity);
  groupEntity.setCpuNum(group.getCpuNum());
  groupEntity.setDefineInstanceNum(group.getInstanceNum());
  groupEntity.setMemorySize(group.getMemCapacityMB());
  groupEntity.setName(group.getName());
  groupEntity.setNodeType(group.getInstanceType());
  PlacementPolicy policies=group.getPlacementPolicies();
  if (policies != null) {
    List<GroupAssociation> associons=policies.getGroupAssociations();
    if (associons != null) {
      Set<NodeGroupAssociation> associonEntities=new TreeSet<NodeGroupAssociation>();
      for (      GroupAssociation a : associons) {
        NodeGroupAssociation ae=new NodeGroupAssociation();
        ae.setAssociationType(a.getType());
        ae.setNodeGroup(groupEntity);
        ae.setReferencedGroup(a.getReference());
        associonEntities.add(ae);
      }
      groupEntity.setGroupAssociations(associonEntities);
    }
    if (policies.getInstancePerHost() != null) {
      groupEntity.setInstancePerHost(policies.getInstancePerHost());
    }
    if (policies.getGroupRacks() != null) {
      groupEntity.setGroupRacks((new Gson()).toJson(policies.getGroupRacks()));
    }
  }
  if (group.getRpNames() != null && group.getRpNames().size() > 0) {
    groupEntity.setVcRpNameList(group.getRpNames());
  }
  if (group.getStorage() != null) {
    groupEntity.setStorageSize(group.getStorage().getSizeGB());
    if (group.getStorage().getType() != null) {
      if (group.getStorage().getType().equals(DatastoreType.LOCAL.name())) {
        groupEntity.setStorageType(DatastoreType.LOCAL);
      }
 else {
        groupEntity.setStorageType(DatastoreType.SHARED);
      }
    }
    groupEntity.setVcDatastoreNameList(group.getStorage().getDsNames());
  }
  List<String> dsNames=groupEntity.getVcDatastoreNameList();
  if (dsNames == null) {
    dsNames=clusterEntity.getVcDatastoreNameList();
  }
  Set<String> sharedPattern=datastoreMgr.getSharedDatastoresByNames(dsNames);
  Set<String> localPattern=datastoreMgr.getLocalDatastoresByNames(dsNames);
  CommonClusterExpandPolicy.expandGroupInstanceType(groupEntity,groupType,sharedPattern,localPattern);
  groupEntity.setHaFlag(group.getHaFlag());
  if (group.getConfiguration() != null && group.getConfiguration().size() > 0) {
    CommonClusterExpandPolicy.validateAppConfig(group.getConfiguration(),validateWhiteList);
    groupEntity.setHadoopConfig(gson.toJson(group.getConfiguration()));
  }
  groupEntity.setVmFolderPath(clusterEntity);
  logger.debug("String_Node_Str" + group.getName());
  return groupEntity;
}