Program: 107467
Project: 107467
Buggy source:
private VmResultObject composeResultObject(UserVmVO vm,ManagementServer ms){
  if (vm == null)   return null;
  VmResultObject resultObj=new VmResultObject();
  Account acct=ms.findAccountById(Long.valueOf(vm.getAccountId()));
  resultObj.setAccount(acct.getAccountName());
  ServiceOfferingVO offering=ms.findServiceOfferingById(vm.getServiceOfferingId());
  resultObj.setCpuSpeed(offering.getSpeed());
  resultObj.setMemory(offering.getRamSize());
  if (offering.getName() != null)   resultObj.setServiceOfferingName(offering.getName());
 else   resultObj.setServiceOfferingName(offering.getDisplayText());
  resultObj.setServiceOfferingId(vm.getServiceOfferingId());
  VmStats vmStats=ms.getVmStatistics(vm.getId());
  if (vmStats != null) {
    resultObj.setCpuUsed((long)vmStats.getCPUUtilization());
    resultObj.setNetworkKbsRead((long)vmStats.getNetworkReadKBs());
    resultObj.setNetworkKbsWrite((long)vmStats.getNetworkWriteKBs());
  }
  resultObj.setCreated(vm.getCreated());
  resultObj.setDisplayName(vm.getDisplayName());
  resultObj.setDomain(ms.findDomainIdById(acct.getDomainId()).getName());
  resultObj.setDomainId(acct.getDomainId());
  resultObj.setHaEnable(vm.isHaEnabled());
  if (vm.getHostId() != null) {
    resultObj.setHostId(vm.getHostId());
    resultObj.setHostName(ms.getHostBy(vm.getHostId()).getName());
  }
  resultObj.setIpAddress(vm.getPrivateIpAddress());
  resultObj.setName(vm.getName());
  resultObj.setState(vm.getState().toString());
  resultObj.setZoneId(vm.getDataCenterId());
  resultObj.setZoneName(ms.findDataCenterById(vm.getDataCenterId()).getName());
  VMTemplateVO template=ms.findTemplateById(vm.getTemplateId());
  resultObj.setPasswordEnabled(template.getEnablePassword());
  resultObj.setTemplateDisplayText(template.getDisplayText());
  resultObj.setTemplateId(template.getId());
  resultObj.setTemplateName(template.getName());
  return resultObj;
}

Fixed version (ground truth):
private VmResultObject composeResultObject(UserVmVO vm,ManagementServer ms){
  if (vm == null)   return null;
  VmResultObject resultObj=new VmResultObject();
  Account acct=ms.findAccountById(Long.valueOf(vm.getAccountId()));
  resultObj.setAccount(acct.getAccountName());
  ServiceOfferingVO offering=ms.findServiceOfferingById(vm.getServiceOfferingId());
  resultObj.setCpuSpeed(offering.getSpeed());
  resultObj.setMemory(offering.getRamSize());
  if (offering.getName() != null)   resultObj.setServiceOfferingName(offering.getName());
 else   resultObj.setServiceOfferingName(offering.getDisplayText());
  resultObj.setServiceOfferingId(vm.getServiceOfferingId());
  VmStats vmStats=ms.getVmStatistics(vm.getId());
  if (vmStats != null) {
    resultObj.setCpuUsed((long)vmStats.getCPUUtilization());
    resultObj.setNetworkKbsRead((long)vmStats.getNetworkReadKBs());
    resultObj.setNetworkKbsWrite((long)vmStats.getNetworkWriteKBs());
  }
  resultObj.setCreated(vm.getCreated());
  resultObj.setDisplayName(vm.getDisplayName());
  resultObj.setDomain(ms.findDomainIdById(acct.getDomainId()).getName());
  resultObj.setDomainId(acct.getDomainId());
  resultObj.setHaEnable(vm.isHaEnabled());
  if (vm.getHostId() != null) {
    resultObj.setHostId(vm.getHostId());
    resultObj.setHostName(ms.getHostBy(vm.getHostId()).getName());
  }
  resultObj.setIpAddress(vm.getPrivateIpAddress());
  resultObj.setName(vm.getName());
  resultObj.setState(vm.getState().toString());
  resultObj.setZoneId(vm.getDataCenterId());
  resultObj.setZoneName(ms.findDataCenterById(vm.getDataCenterId()).getName());
  VMTemplateVO template=ms.findTemplateById(vm.getTemplateId());
  resultObj.setPasswordEnabled(template.getEnablePassword());
  resultObj.setTemplateDisplayText(template.getDisplayText());
  resultObj.setTemplateId(template.getId());
  resultObj.setTemplateName(template.getName());
  resultObj.setId(vm.getId());
  return resultObj;
}