Program: 49079
Project: 49079
Buggy source:
public void validateIfHostCanSatisfied(int instanceNum){
  if (getInstancePerHost() != null) {
    int requiredHostNum=instanceNum / getInstancePerHost();
    if (getGroupRacks() != null) {
      GroupRacks groupRacks=(GroupRacks)new Gson().fromJson(getGroupRacks(),GroupRacks.class);
      GroupRacksType rackType=groupRacks.getType();
      List<RackInfo> racksInfo=new RackInfoManager().exportRackInfo();
      Set<String> specifiedRacks=new HashSet<String>(Arrays.asList(groupRacks.getRacks()));
      List<String> IntersecRacks=new ArrayList<String>();
      Integer IntersecHostNum=0;
      Integer maxIntersecHostNum=0;
      for (      RackInfo rackInfo : racksInfo) {
        if (specifiedRacks.isEmpty() || specifiedRacks.size() == 0 || specifiedRacks.contains(rackInfo.getName())) {
          IntersecHostNum+=rackInfo.getHosts().size();
          IntersecRacks.add(rackInfo.getName());
          if (rackInfo.getHosts().size() > maxIntersecHostNum) {
            maxIntersecHostNum=rackInfo.getHosts().size();
          }
        }
      }
      if (rackType.equals(GroupRacksType.ROUNDROBIN) && IntersecHostNum < requiredHostNum) {
        throw ClusterConfigException.LACK_PHYSICAL_HOSTS(this.name,requiredHostNum,IntersecHostNum);
      }
 else       if (rackType.equals(GroupRacksType.SAMERACK) && requiredHostNum > maxIntersecHostNum) {
        throw ClusterConfigException.LACK_PHYSICAL_HOSTS(this.name,requiredHostNum,maxIntersecHostNum);
      }
      groupRacks.setRacks(IntersecRacks.toArray(new String[IntersecRacks.size()]));
      setGroupRacks((new Gson()).toJson(groupRacks));
    }
  }
}

Fixed version (ground truth):
public void validateIfHostCanSatisfied(int instanceNum){
  if (getInstancePerHost() != null) {
    int requiredHostNum=instanceNum / getInstancePerHost();
    if (getGroupRacks() != null) {
      GroupRacks groupRacks=(GroupRacks)new Gson().fromJson(getGroupRacks(),GroupRacks.class);
      GroupRacksType rackType=groupRacks.getType();
      List<RackInfo> racksInfo=new RackInfoManager().exportRackInfo();
      Set<String> specifiedRacks=new HashSet<String>(Arrays.asList(groupRacks.getRacks()));
      List<String> IntersecRacks=new ArrayList<String>();
      Integer IntersecHostNum=0;
      Integer maxIntersecHostNum=0;
      for (      RackInfo rackInfo : racksInfo) {
        if (specifiedRacks.isEmpty() || specifiedRacks.size() == 0 || specifiedRacks.contains(rackInfo.getName())) {
          IntersecHostNum+=rackInfo.getHosts().size();
          IntersecRacks.add(rackInfo.getName());
          if (rackInfo.getHosts().size() > maxIntersecHostNum) {
            maxIntersecHostNum=rackInfo.getHosts().size();
          }
        }
      }
      if (rackType.equals(GroupRacksType.ROUNDROBIN) && IntersecHostNum < requiredHostNum) {
        throw ClusterConfigException.LACK_PHYSICAL_HOSTS(this.name,requiredHostNum,IntersecHostNum);
      }
 else       if (rackType.equals(GroupRacksType.SAMERACK) && requiredHostNum > maxIntersecHostNum) {
        throw ClusterConfigException.LACK_PHYSICAL_HOSTS(this.name,requiredHostNum,maxIntersecHostNum);
      }
      if (specifiedRacks.isEmpty()) {
        groupRacks.setRacks(new String[0]);
      }
 else {
        groupRacks.setRacks(IntersecRacks.toArray(new String[IntersecRacks.size()]));
      }
      setGroupRacks((new Gson()).toJson(groupRacks));
    }
  }
}