Program: 48584
Project: 48584
Buggy source:
private NodeGroupEntity convertGroup(Gson gson,ClusterEntity clusterEntity,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());
  }
  groupEntity.setCluster(clusterEntity);
  int cpuNum=group.getCpuNum() == null ? 0 : group.getCpuNum();
  if (!VcVmUtil.validateCPU(clusteringService.getTemplateVmId(),cpuNum)) {
    throw VcProviderException.CPU_NUM_NOT_MULTIPLE_OF_CORES_PER_SOCKET(group.getName(),clusteringService.getTemplateVmName());
  }
  groupEntity.setCpuNum(cpuNum);
  groupEntity.setDefineInstanceNum(group.getInstanceNum());
  groupEntity.setMemorySize(group.getMemCapacityMB() == null ? 0 : group.getMemCapacityMB());
  groupEntity.setSwapRatio(group.getSwapRatio());
  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 HashSet<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());
  }
  Set<String> roles=new LinkedHashSet<String>();
  convertStorage(group,groupEntity,roles);
  roles.addAll(group.getRoles());
  groupEntity.setRoles(gson.toJson(roles));
  if (group.getInstanceNum() <= 0) {
    logger.warn("String_Node_Str" + group.getName() + "String_Node_Str");
    return null;
  }
  List<String> dsNames=groupEntity.getVcDatastoreNameList();
  if (dsNames == null) {
    dsNames=clusterEntity.getVcDatastoreNameList();
  }
  Set<String> sharedPattern;
  Set<String> localPattern;
  if (dsNames != null) {
    sharedPattern=datastoreMgr.getSharedDatastoresByNames(dsNames);
    localPattern=datastoreMgr.getLocalDatastoresByNames(dsNames);
  }
 else {
    sharedPattern=datastoreMgr.getAllSharedDatastores();
    localPattern=datastoreMgr.getAllLocalDatastores();
  }
  SoftwareManager softwareManager=getSoftwareManager(clusterEntity.getAppManager());
  CommonClusterExpandPolicy.expandGroupInstanceType(groupEntity,group,sharedPattern,localPattern,softwareManager);
  groupEntity.setHaFlag(group.getHaFlag());
  if (group.getConfiguration() != null && group.getConfiguration().size() > 0) {
    groupEntity.setHadoopConfig(gson.toJson(group.getConfiguration()));
  }
  groupEntity.setVmFolderPath(clusterEntity);
  logger.debug("String_Node_Str" + group.getName());
  return groupEntity;
}

Fixed version (ground truth):
private NodeGroupEntity convertGroup(Gson gson,ClusterEntity clusterEntity,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());
  }
  groupEntity.setCluster(clusterEntity);
  int cpuNum=group.getCpuNum() == null ? 0 : group.getCpuNum();
  if (!VcVmUtil.validateCPU(clusteringService.getTemplateVmId(),cpuNum)) {
    throw VcProviderException.CPU_NUM_NOT_MULTIPLE_OF_CORES_PER_SOCKET(group.getName(),clusteringService.getTemplateVmName());
  }
  groupEntity.setCpuNum(cpuNum);
  groupEntity.setDefineInstanceNum(group.getInstanceNum());
  groupEntity.setMemorySize(group.getMemCapacityMB() == null ? 0 : group.getMemCapacityMB());
  groupEntity.setSwapRatio(group.getSwapRatio());
  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 HashSet<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());
  }
  Set<String> roles=new LinkedHashSet<String>();
  convertStorage(group,groupEntity,roles);
  roles.addAll(group.getRoles());
  groupEntity.setRoles(gson.toJson(roles));
  if (group.getInstanceNum() <= 0) {
    logger.warn("String_Node_Str" + group.getName() + "String_Node_Str");
    return null;
  }
  List<String> dsNames=groupEntity.getVcDatastoreNameList();
  if (dsNames == null) {
    dsNames=clusterEntity.getVcDatastoreNameList();
  }
  Set<String> sharedPattern;
  Set<String> localPattern;
  if (dsNames != null) {
    sharedPattern=datastoreMgr.getSharedDatastoresByNames(dsNames);
    localPattern=datastoreMgr.getLocalDatastoresByNames(dsNames);
  }
 else {
    sharedPattern=datastoreMgr.getAllSharedDatastores();
    localPattern=datastoreMgr.getAllLocalDatastores();
  }
  SoftwareManager softwareManager=getSoftwareManager(clusterEntity.getAppManager());
  CommonClusterExpandPolicy.expandGroupInstanceType(groupEntity,group,sharedPattern,localPattern,softwareManager);
  String haFlag=group.getHaFlag();
  if (haFlag == null) {
    groupEntity.setHaFlag(Constants.HA_FLAG_OFF);
  }
 else {
    groupEntity.setHaFlag(haFlag);
  }
  if (group.getConfiguration() != null && group.getConfiguration().size() > 0) {
    groupEntity.setHadoopConfig(gson.toJson(group.getConfiguration()));
  }
  groupEntity.setVmFolderPath(clusterEntity);
  logger.debug("String_Node_Str" + group.getName());
  return groupEntity;
}