Program: 105564
Project: 105564
Buggy source:
@Override public void recalculateCapacity(){
  try {
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str");
      s_logger.debug("String_Node_Str");
    }
    List<HostVO> hosts=_resourceMgr.listAllNotInMaintenanceHostsInOneZone(Host.Type.Routing,null);
    for (    HostVO host : hosts) {
      _capacityMgr.updateCapacityForHost(host);
    }
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str");
      s_logger.debug("String_Node_Str");
    }
    List<StoragePoolVO> storagePools=_storagePoolDao.listAll();
    for (    StoragePoolVO pool : storagePools) {
      long disk=_capacityMgr.getAllocatedPoolCapacity(pool,null);
      if (pool.isShared()) {
        _storageMgr.createCapacityEntry(pool,Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED,disk);
      }
 else {
        _storageMgr.createCapacityEntry(pool,Capacity.CAPACITY_TYPE_LOCAL_STORAGE,disk);
      }
    }
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str");
      s_logger.debug("String_Node_Str");
    }
    List<DataCenterVO> datacenters=_dcDao.listAll();
    for (    DataCenterVO datacenter : datacenters) {
      long dcId=datacenter.getId();
      if (datacenter.getNetworkType() == NetworkType.Advanced) {
        createOrUpdateIpCapacity(dcId,null,Capacity.CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP,datacenter.getAllocationState());
      }
      createOrUpdateIpCapacity(dcId,null,Capacity.CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP,datacenter.getAllocationState());
      if (datacenter.getNetworkType() == NetworkType.Advanced) {
        createOrUpdateVlanCapacity(dcId,datacenter.getAllocationState());
      }
    }
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str");
      s_logger.debug("String_Node_Str");
    }
    List<HostPodVO> pods=_podDao.listAll();
    for (    HostPodVO pod : pods) {
      long podId=pod.getId();
      long dcId=pod.getDataCenterId();
      createOrUpdateIpCapacity(dcId,podId,Capacity.CAPACITY_TYPE_PRIVATE_IP,_configMgr.findPodAllocationState(pod));
    }
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str");
      s_logger.debug("String_Node_Str");
    }
  }
 catch (  Throwable t) {
    s_logger.error("String_Node_Str",t);
  }
}

Fixed version (ground truth):
@Override public void recalculateCapacity(){
  try {
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str");
      s_logger.debug("String_Node_Str");
    }
    List<HostVO> hosts=_resourceMgr.listAllNotInMaintenanceHostsInOneZone(Host.Type.Routing,null);
    if (hosts != null) {
      for (      HostVO host : hosts) {
        _capacityMgr.updateCapacityForHost(host);
      }
    }
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str");
      s_logger.debug("String_Node_Str");
    }
    List<StoragePoolVO> storagePools=_storagePoolDao.listAll();
    for (    StoragePoolVO pool : storagePools) {
      long disk=_capacityMgr.getAllocatedPoolCapacity(pool,null);
      if (pool.isShared()) {
        _storageMgr.createCapacityEntry(pool,Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED,disk);
      }
 else {
        _storageMgr.createCapacityEntry(pool,Capacity.CAPACITY_TYPE_LOCAL_STORAGE,disk);
      }
    }
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str");
      s_logger.debug("String_Node_Str");
    }
    List<DataCenterVO> datacenters=_dcDao.listAll();
    for (    DataCenterVO datacenter : datacenters) {
      long dcId=datacenter.getId();
      if (datacenter.getNetworkType() == NetworkType.Advanced) {
        createOrUpdateIpCapacity(dcId,null,Capacity.CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP,datacenter.getAllocationState());
      }
      createOrUpdateIpCapacity(dcId,null,Capacity.CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP,datacenter.getAllocationState());
      if (datacenter.getNetworkType() == NetworkType.Advanced) {
        createOrUpdateVlanCapacity(dcId,datacenter.getAllocationState());
      }
    }
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str");
      s_logger.debug("String_Node_Str");
    }
    List<HostPodVO> pods=_podDao.listAll();
    for (    HostPodVO pod : pods) {
      long podId=pod.getId();
      long dcId=pod.getDataCenterId();
      createOrUpdateIpCapacity(dcId,podId,Capacity.CAPACITY_TYPE_PRIVATE_IP,_configMgr.findPodAllocationState(pod));
    }
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str");
      s_logger.debug("String_Node_Str");
    }
  }
 catch (  Throwable t) {
    s_logger.error("String_Node_Str",t);
  }
}