Program: 49115
Project: 49115
Buggy source:
private boolean validateRacksInfo(ClusterCreate cluster,List<String> failedMsgList){
  boolean valid=true;
  Map<String,NodeGroupCreate> allGroups=new TreeMap<String,NodeGroupCreate>();
  if (cluster.getNodeGroups() == null) {
    return valid;
  }
  for (  NodeGroupCreate nodeGroupCreate : cluster.getNodeGroups()) {
    allGroups.put(nodeGroupCreate.getName(),nodeGroupCreate);
  }
  for (  NodeGroupCreate ngc : cluster.getNodeGroups()) {
    PlacementPolicy policies=ngc.getPlacementPolicies();
    if (policies != null && policies.getGroupRacks() != null && ngc.calculateHostNum() != null) {
      Integer requiredHostNum=ngc.calculateHostNum();
      if (requiredHostNum > 0) {
        GroupRacks r=policies.getGroupRacks();
        Integer totalHostNum=0;
        List<RackInfo> racksInfo=rackInfoMgr.exportRackInfo();
        Set<String> totalRacks=new HashSet<String>(Arrays.asList(r.getRacks()));
        for (        RackInfo rackInfo : racksInfo) {
          if (totalRacks.isEmpty()) {
            totalHostNum+=rackInfo.getHosts().size();
          }
 else           if (totalRacks.contains(rackInfo.getName())) {
            totalHostNum+=rackInfo.getHosts().size();
          }
        }
        if (totalHostNum < requiredHostNum) {
          valid=false;
          throw ClusterConfigException.LACK_PHYSICAL_HOSTS();
        }
      }
    }
  }
  return valid;
}

Fixed version (ground truth):
private boolean validateRacksInfo(ClusterCreate cluster,List<String> failedMsgList){
  boolean valid=true;
  Map<String,NodeGroupCreate> allGroups=new TreeMap<String,NodeGroupCreate>();
  if (cluster.getNodeGroups() == null) {
    return valid;
  }
  for (  NodeGroupCreate nodeGroupCreate : cluster.getNodeGroups()) {
    allGroups.put(nodeGroupCreate.getName(),nodeGroupCreate);
  }
  for (  NodeGroupCreate ngc : cluster.getNodeGroups()) {
    PlacementPolicy policies=ngc.getPlacementPolicies();
    if (policies != null && policies.getGroupAssociations() != null && policies.getGroupAssociations().get(0).getType() == GroupAssociationType.STRICT) {
      continue;
    }
    if (ngc.getStorage() != null && ngc.getStorage().getType() != null && ngc.getStorage().getType().equals(DatastoreType.SHARED.toString())) {
      continue;
    }
    if (policies != null && policies.getGroupRacks() != null && ngc.calculateHostNum() != null) {
      Integer requiredHostNum=ngc.calculateHostNum();
      if (requiredHostNum > 0) {
        GroupRacks r=policies.getGroupRacks();
        Integer totalHostNum=0;
        List<RackInfo> racksInfo=rackInfoMgr.exportRackInfo();
        Set<String> totalRacks=new HashSet<String>(Arrays.asList(r.getRacks()));
        for (        RackInfo rackInfo : racksInfo) {
          if (totalRacks.isEmpty()) {
            totalHostNum+=rackInfo.getHosts().size();
          }
 else           if (totalRacks.contains(rackInfo.getName())) {
            totalHostNum+=rackInfo.getHosts().size();
          }
        }
        if (totalHostNum < requiredHostNum) {
          valid=false;
          throw ClusterConfigException.LACK_PHYSICAL_HOSTS(ngc.getName(),requiredHostNum,totalHostNum);
        }
      }
    }
  }
  return valid;
}