Program: 89323
Project: 89323
Buggy source:
@Override public HostResponse createHostResponse(Host host){
  HostResponse hostResponse=new HostResponse();
  hostResponse.setId(host.getId());
  hostResponse.setCapabilities(host.getCapabilities());
  hostResponse.setClusterId(host.getClusterId());
  hostResponse.setCpuNumber(host.getCpus());
  hostResponse.setZoneId(host.getDataCenterId());
  hostResponse.setDisconnectedOn(host.getDisconnectedOn());
  hostResponse.setHypervisor(host.getHypervisorType());
  hostResponse.setHostType(host.getType());
  hostResponse.setLastPinged(new Date(host.getLastPinged()));
  hostResponse.setManagementServerId(host.getManagementServerId());
  hostResponse.setName(host.getName());
  hostResponse.setPodId(host.getPodId());
  hostResponse.setRemoved(host.getRemoved());
  hostResponse.setCpuSpeed(host.getSpeed());
  hostResponse.setState(host.getStatus());
  hostResponse.setIpAddress(host.getPrivateIpAddress());
  hostResponse.setVersion(host.getVersion());
  hostResponse.setCreated(host.getCreated());
  GuestOSCategoryVO guestOSCategory=ApiDBUtils.getHostGuestOSCategory(host.getId());
  if (guestOSCategory != null) {
    hostResponse.setOsCategoryId(guestOSCategory.getId());
    hostResponse.setOsCategoryName(guestOSCategory.getName());
  }
  hostResponse.setZoneName(ApiDBUtils.findZoneById(host.getDataCenterId()).getName());
  if (host.getPodId() != null) {
    HostPodVO pod=ApiDBUtils.findPodById(host.getPodId());
    if (pod != null) {
      hostResponse.setPodName(pod.getName());
    }
  }
  DecimalFormat decimalFormat=new DecimalFormat("String_Node_Str");
  if ((host.getCpus() != null) && (host.getSpeed() != null)) {
    int cpu=0;
    String cpuAlloc=null;
    List<UserVmVO> instances=ApiDBUtils.listUserVMsByHostId(host.getId());
    for (    UserVmVO vm : instances) {
      ServiceOffering so=ApiDBUtils.findServiceOfferingById(vm.getServiceOfferingId());
      cpu+=so.getCpu() * so.getSpeed();
    }
    cpuAlloc=decimalFormat.format(((float)cpu / (float)(host.getCpus() * host.getSpeed())) * 100f) + "String_Node_Str";
    hostResponse.setCpuAllocated(cpuAlloc);
    String cpuWithOverprovisioning=new Float(host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor()).toString();
    hostResponse.setCpuWithOverprovisioning(cpuWithOverprovisioning);
  }
  String cpuUsed=null;
  HostStats hostStats=ApiDBUtils.getHostStatistics(host.getId());
  if (hostStats != null) {
    float cpuUtil=(float)hostStats.getCpuUtilization();
    cpuUsed=decimalFormat.format(cpuUtil) + "String_Node_Str";
    hostResponse.setCpuUsed(cpuUsed);
    hostResponse.setNetworkKbsRead((new Double(hostStats.getNetworkReadKBs())).longValue());
    hostResponse.setNetworkKbsWrite((new Double(hostStats.getNetworkWriteKBs())).longValue());
  }
  if (host.getType() == Host.Type.Routing) {
    hostResponse.setMemoryTotal(host.getTotalMemory());
    Long mem=ApiDBUtils.getMemoryUsagebyHost(host.getId());
    hostResponse.setMemoryAllocated(mem);
    hostResponse.setMemoryUsed(mem);
    hostResponse.setHostTags(ApiDBUtils.getHostTags(host.getId()));
    hostResponse.setHypervisorVersion(host.getHypervisorVersion());
  }
 else   if (host.getType().toString().equals("String_Node_Str")) {
    hostResponse.setDiskSizeTotal(host.getTotalSize());
    hostResponse.setDiskSizeAllocated(0L);
  }
  if (host.getClusterId() != null) {
    ClusterVO cluster=ApiDBUtils.findClusterById(host.getClusterId());
    hostResponse.setClusterName(cluster.getName());
    hostResponse.setClusterType(cluster.getClusterType().toString());
  }
  hostResponse.setLocalStorageActive(ApiDBUtils.isLocalStorageActiveOnHost(host));
  Set<com.cloud.host.Status.Event> possibleEvents=host.getStatus().getPossibleEvents();
  if ((possibleEvents != null) && !possibleEvents.isEmpty()) {
    String events="String_Node_Str";
    Iterator<com.cloud.host.Status.Event> iter=possibleEvents.iterator();
    while (iter.hasNext()) {
      com.cloud.host.Status.Event event=iter.next();
      events+=event.toString();
      if (iter.hasNext()) {
        events+="String_Node_Str";
      }
    }
    hostResponse.setEvents(events);
  }
  hostResponse.setAllocationState(host.getHostAllocationState().toString());
  hostResponse.setObjectName("String_Node_Str");
  return hostResponse;
}

Fixed version (ground truth):
@Override public HostResponse createHostResponse(Host host){
  HostResponse hostResponse=new HostResponse();
  hostResponse.setId(host.getId());
  hostResponse.setCapabilities(host.getCapabilities());
  hostResponse.setClusterId(host.getClusterId());
  hostResponse.setCpuNumber(host.getCpus());
  hostResponse.setZoneId(host.getDataCenterId());
  hostResponse.setDisconnectedOn(host.getDisconnectedOn());
  hostResponse.setHypervisor(host.getHypervisorType());
  hostResponse.setHostType(host.getType());
  hostResponse.setLastPinged(new Date(host.getLastPinged()));
  hostResponse.setManagementServerId(host.getManagementServerId());
  hostResponse.setName(host.getName());
  hostResponse.setPodId(host.getPodId());
  hostResponse.setRemoved(host.getRemoved());
  hostResponse.setCpuSpeed(host.getSpeed());
  hostResponse.setState(host.getStatus());
  hostResponse.setIpAddress(host.getPrivateIpAddress());
  hostResponse.setVersion(host.getVersion());
  hostResponse.setCreated(host.getCreated());
  GuestOSCategoryVO guestOSCategory=ApiDBUtils.getHostGuestOSCategory(host.getId());
  if (guestOSCategory != null) {
    hostResponse.setOsCategoryId(guestOSCategory.getId());
    hostResponse.setOsCategoryName(guestOSCategory.getName());
  }
  hostResponse.setZoneName(ApiDBUtils.findZoneById(host.getDataCenterId()).getName());
  if (host.getPodId() != null) {
    HostPodVO pod=ApiDBUtils.findPodById(host.getPodId());
    if (pod != null) {
      hostResponse.setPodName(pod.getName());
    }
  }
  DecimalFormat decimalFormat=new DecimalFormat("String_Node_Str");
  if (host.getType() == Host.Type.Routing) {
    Long mem=ApiDBUtils.getMemoryOrCpuCapacitybyHost(host.getId(),Capacity.CAPACITY_TYPE_MEMORY);
    Long cpu=ApiDBUtils.getMemoryOrCpuCapacitybyHost(host.getId(),Capacity.CAPACITY_TYPE_CPU);
    hostResponse.setMemoryAllocated(mem);
    hostResponse.setMemoryTotal(host.getTotalMemory());
    hostResponse.setHostTags(ApiDBUtils.getHostTags(host.getId()));
    hostResponse.setHypervisorVersion(host.getHypervisorVersion());
    String cpuAlloc=decimalFormat.format(((float)cpu / (float)(host.getCpus() * host.getSpeed())) * 100f) + "String_Node_Str";
    hostResponse.setCpuAllocated(cpuAlloc);
    String cpuWithOverprovisioning=new Float(host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor()).toString();
    hostResponse.setCpuWithOverprovisioning(cpuWithOverprovisioning);
    String cpuUsed=null;
    HostStats hostStats=ApiDBUtils.getHostStatistics(host.getId());
    if (hostStats != null) {
      float cpuUtil=(float)hostStats.getCpuUtilization();
      cpuUsed=decimalFormat.format(cpuUtil) + "String_Node_Str";
      hostResponse.setCpuUsed(cpuUsed);
      hostResponse.setMemoryUsed((new Double(hostStats.getUsedMemory())).longValue());
      hostResponse.setNetworkKbsRead((new Double(hostStats.getNetworkReadKBs())).longValue());
      hostResponse.setNetworkKbsWrite((new Double(hostStats.getNetworkWriteKBs())).longValue());
    }
  }
  if (host.getClusterId() != null) {
    ClusterVO cluster=ApiDBUtils.findClusterById(host.getClusterId());
    hostResponse.setClusterName(cluster.getName());
    hostResponse.setClusterType(cluster.getClusterType().toString());
  }
  hostResponse.setLocalStorageActive(ApiDBUtils.isLocalStorageActiveOnHost(host));
  Set<com.cloud.host.Status.Event> possibleEvents=host.getStatus().getPossibleEvents();
  if ((possibleEvents != null) && !possibleEvents.isEmpty()) {
    String events="String_Node_Str";
    Iterator<com.cloud.host.Status.Event> iter=possibleEvents.iterator();
    while (iter.hasNext()) {
      com.cloud.host.Status.Event event=iter.next();
      events+=event.toString();
      if (iter.hasNext()) {
        events+="String_Node_Str";
      }
    }
    hostResponse.setEvents(events);
  }
  hostResponse.setAllocationState(host.getHostAllocationState().toString());
  hostResponse.setObjectName("String_Node_Str");
  return hostResponse;
}