Program: 89295
Project: 89295
Buggy source:
public void checkForAlerts(){
  recalculateCapacity();
  if (_emailAlert == null) {
    return;
  }
  List<DataCenterVO> dataCenterList=_dcDao.listAll();
  List<ClusterVO> clusterList=_clusterDao.listAll();
  List<HostPodVO> podList=_podDao.listAll();
  List<Short> dataCenterCapacityTypes=getCapacityTypesAtZoneLevel();
  List<Short> podCapacityTypes=getCapacityTypesAtPodLevel();
  List<Short> clusterCapacityTypes=getCapacityTypesAtClusterLevel();
  for (  DataCenterVO dc : dataCenterList) {
    for (    Short capacityType : dataCenterCapacityTypes) {
      List<SummedCapacity> capacity=_capacityDao.findCapacityBy(capacityType.intValue(),dc.getId(),null,null);
      if (capacity == null || capacity.size() == 0) {
        continue;
      }
      double totalCapacity=capacity.get(0).getTotalCapacity();
      double usedCapacity=capacity.get(0).getUsedCapacity();
      if (totalCapacity != 0 && usedCapacity / totalCapacity > _capacityTypeThresholdMap.get(capacityType)) {
        generateEmailAlert(dc,null,null,totalCapacity,usedCapacity,capacityType);
      }
    }
  }
  for (  HostPodVO pod : podList) {
    for (    Short capacityType : podCapacityTypes) {
      List<SummedCapacity> capacity=_capacityDao.findCapacityBy(capacityType.intValue(),pod.getDataCenterId(),pod.getId(),null);
      if (capacity == null || capacity.size() == 0) {
        continue;
      }
      double totalCapacity=capacity.get(0).getTotalCapacity();
      double usedCapacity=capacity.get(0).getUsedCapacity();
      if (totalCapacity != 0 && usedCapacity / totalCapacity > _capacityTypeThresholdMap.get(capacityType)) {
        generateEmailAlert(ApiDBUtils.findZoneById(pod.getDataCenterId()),pod,null,totalCapacity,usedCapacity,capacityType);
      }
    }
  }
  for (  ClusterVO cluster : clusterList) {
    for (    Short capacityType : clusterCapacityTypes) {
      List<SummedCapacity> capacity=_capacityDao.findCapacityBy(capacityType.intValue(),cluster.getDataCenterId(),null,cluster.getId());
      if (capacity == null || capacity.size() == 0) {
        continue;
      }
      double totalCapacity=capacity.get(0).getTotalCapacity();
      double usedCapacity=capacity.get(0).getUsedCapacity();
      if (totalCapacity != 0 && usedCapacity / totalCapacity > _capacityTypeThresholdMap.get(capacityType)) {
        generateEmailAlert(ApiDBUtils.findZoneById(cluster.getDataCenterId()),ApiDBUtils.findPodById(cluster.getPodId()),cluster,totalCapacity,usedCapacity,capacityType);
      }
    }
  }
}

Fixed version (ground truth):
public void checkForAlerts(){
  recalculateCapacity();
  if (_emailAlert == null) {
    return;
  }
  List<DataCenterVO> dataCenterList=_dcDao.listAll();
  List<ClusterVO> clusterList=_clusterDao.listAll();
  List<HostPodVO> podList=_podDao.listAll();
  List<Short> dataCenterCapacityTypes=getCapacityTypesAtZoneLevel();
  List<Short> podCapacityTypes=getCapacityTypesAtPodLevel();
  List<Short> clusterCapacityTypes=getCapacityTypesAtClusterLevel();
  for (  DataCenterVO dc : dataCenterList) {
    for (    Short capacityType : dataCenterCapacityTypes) {
      List<SummedCapacity> capacity=new ArrayList<SummedCapacity>();
      capacity=_capacityDao.findCapacityBy(capacityType.intValue(),dc.getId(),null,null);
      if (capacityType == Capacity.CAPACITY_TYPE_SECONDARY_STORAGE) {
        capacity.add(getUsedStats(capacityType,dc.getId(),null,null));
      }
      if (capacity == null || capacity.size() == 0) {
        continue;
      }
      double totalCapacity=capacity.get(0).getTotalCapacity();
      double usedCapacity=capacity.get(0).getUsedCapacity();
      if (totalCapacity != 0 && usedCapacity / totalCapacity > _capacityTypeThresholdMap.get(capacityType)) {
        generateEmailAlert(dc,null,null,totalCapacity,usedCapacity,capacityType);
      }
    }
  }
  for (  HostPodVO pod : podList) {
    for (    Short capacityType : podCapacityTypes) {
      List<SummedCapacity> capacity=_capacityDao.findCapacityBy(capacityType.intValue(),pod.getDataCenterId(),pod.getId(),null);
      if (capacity == null || capacity.size() == 0) {
        continue;
      }
      double totalCapacity=capacity.get(0).getTotalCapacity();
      double usedCapacity=capacity.get(0).getUsedCapacity();
      if (totalCapacity != 0 && usedCapacity / totalCapacity > _capacityTypeThresholdMap.get(capacityType)) {
        generateEmailAlert(ApiDBUtils.findZoneById(pod.getDataCenterId()),pod,null,totalCapacity,usedCapacity,capacityType);
      }
    }
  }
  for (  ClusterVO cluster : clusterList) {
    for (    Short capacityType : clusterCapacityTypes) {
      List<SummedCapacity> capacity=new ArrayList<SummedCapacity>();
      float overProvFactor=1f;
      capacity=_capacityDao.findCapacityBy(capacityType.intValue(),cluster.getDataCenterId(),null,cluster.getId());
      if (capacityType == Capacity.CAPACITY_TYPE_STORAGE) {
        capacity.add(getUsedStats(capacityType,cluster.getDataCenterId(),cluster.getPodId(),cluster.getId()));
      }
      if (capacity == null || capacity.size() == 0) {
        continue;
      }
      if (capacityType == Capacity.CAPACITY_TYPE_CPU) {
        overProvFactor=ApiDBUtils.getCpuOverprovisioningFactor();
      }
      double totalCapacity=capacity.get(0).getTotalCapacity() * overProvFactor;
      double usedCapacity=capacity.get(0).getUsedCapacity() + capacity.get(0).getReservedCapacity();
      if (totalCapacity != 0 && usedCapacity / totalCapacity > _capacityTypeThresholdMap.get(capacityType)) {
        generateEmailAlert(ApiDBUtils.findZoneById(cluster.getDataCenterId()),ApiDBUtils.findPodById(cluster.getPodId()),cluster,totalCapacity,usedCapacity,capacityType);
      }
    }
  }
}