Program: 89916
Project: 89916
Buggy source:
private DeployVMResultObject composeResultObject(long userId,UserVm vm,DeployVMParam param){
  DeployVMResultObject resultObject=new DeployVMResultObject();
  if (vm == null)   return resultObject;
  resultObject.setId(vm.getId());
  resultObject.setName(vm.getHostName());
  resultObject.setCreated(vm.getCreated());
  resultObject.setZoneId(vm.getDataCenterId());
  resultObject.setZoneName(getAsyncJobMgr().getExecutorContext().getManagementServer().findDataCenterById(vm.getDataCenterId()).getName());
  resultObject.setIpAddress(vm.getPrivateIpAddress());
  resultObject.setServiceOfferingId(vm.getServiceOfferingId());
  resultObject.setHaEnabled(vm.isHaEnabled());
  if (vm.getDisplayName() == null || vm.getDisplayName().length() == 0) {
    resultObject.setDisplayName(vm.getHostName());
  }
 else {
    resultObject.setDisplayName(vm.getDisplayName());
  }
  if (vm.getState() != null)   resultObject.setState(vm.getState().toString());
  ManagementServer managementServer=getAsyncJobMgr().getExecutorContext().getManagementServer();
  InstanceGroupVO group=managementServer.getGroupForVm(vm.getId());
  if (group != null) {
    resultObject.setGroupId(group.getId());
    resultObject.setGroup(group.getName());
  }
  VMTemplateVO template=managementServer.findTemplateById(vm.getTemplateId());
  Account acct=managementServer.findAccountById(Long.valueOf(vm.getAccountId()));
  if (acct != null) {
    resultObject.setAccount(acct.getAccountName());
    resultObject.setDomainId(acct.getDomainId());
  }
  User userExecutingCmd=managementServer.getUser(userId);
  Account acctForUserExecutingCmd=managementServer.findAccountById(Long.valueOf(userExecutingCmd.getAccountId()));
  if ((BaseCmd.isAdmin(acctForUserExecutingCmd.getType()) && (vm.getHostId() != null)) || (BaseCmd.isAdmin(acct.getType()) && (vm.getHostId() != null))) {
    resultObject.setHostname(managementServer.getHostBy(vm.getHostId()).getName());
    resultObject.setHostid(vm.getHostId());
  }
  String templateName="String_Node_Str";
  boolean templatePasswordEnabled=false;
  String templateDisplayText=null;
  if (template != null) {
    templateName=template.getName();
    templatePasswordEnabled=template.getEnablePassword();
    templateDisplayText=template.getDisplayText();
    if (templateDisplayText == null) {
      templateDisplayText=templateName;
    }
  }
  if (templatePasswordEnabled) {
    resultObject.setPassword(param.getPassword());
  }
  Long isoId=vm.getIsoId();
  if (isoId != null) {
    VMTemplateVO iso=getAsyncJobMgr().getExecutorContext().getManagementServer().findTemplateById(isoId.longValue());
    if (iso != null) {
      resultObject.setIsoId(isoId.longValue());
      resultObject.setIsoName(iso.getName());
      resultObject.setTemplateId(isoId.longValue());
      resultObject.setTemplateName(iso.getName());
      templateDisplayText=iso.getDisplayText();
      if (templateDisplayText == null)       templateDisplayText=iso.getName();
      resultObject.setIsoDisplayText(templateDisplayText);
      resultObject.setTemplateDisplayText(templateDisplayText);
    }
  }
 else {
    resultObject.setTemplateId(vm.getTemplateId());
    resultObject.setTemplateName(templateName);
    resultObject.setTemplateDisplayText(templateDisplayText);
    resultObject.setPasswordEnabled(templatePasswordEnabled);
  }
  ServiceOfferingVO offering=managementServer.findServiceOfferingById(vm.getServiceOfferingId());
  resultObject.setServiceOfferingId(vm.getServiceOfferingId());
  resultObject.setServiceOfferingName(offering.getName());
  resultObject.setCpuNumber(String.valueOf(offering.getCpu()));
  resultObject.setCpuSpeed(String.valueOf(offering.getSpeed()));
  resultObject.setMemory(String.valueOf(offering.getRamSize()));
  return resultObject;
}

Fixed version (ground truth):
private DeployVMResultObject composeResultObject(long userId,UserVm vm,DeployVMParam param){
  DeployVMResultObject resultObject=new DeployVMResultObject();
  if (vm == null)   return resultObject;
  resultObject.setId(vm.getId());
  resultObject.setName(vm.getName());
  resultObject.setCreated(vm.getCreated());
  resultObject.setZoneId(vm.getDataCenterId());
  resultObject.setZoneName(getAsyncJobMgr().getExecutorContext().getManagementServer().findDataCenterById(vm.getDataCenterId()).getName());
  resultObject.setIpAddress(vm.getPrivateIpAddress());
  resultObject.setServiceOfferingId(vm.getServiceOfferingId());
  resultObject.setHaEnabled(vm.isHaEnabled());
  if (vm.getDisplayName() == null || vm.getDisplayName().length() == 0) {
    resultObject.setDisplayName(vm.getName());
  }
 else {
    resultObject.setDisplayName(vm.getDisplayName());
  }
  if (vm.getState() != null)   resultObject.setState(vm.getState().toString());
  ManagementServer managementServer=getAsyncJobMgr().getExecutorContext().getManagementServer();
  InstanceGroupVO group=managementServer.getGroupForVm(vm.getId());
  if (group != null) {
    resultObject.setGroupId(group.getId());
    resultObject.setGroup(group.getName());
  }
  VMTemplateVO template=managementServer.findTemplateById(vm.getTemplateId());
  Account acct=managementServer.findAccountById(Long.valueOf(vm.getAccountId()));
  if (acct != null) {
    resultObject.setAccount(acct.getAccountName());
    resultObject.setDomainId(acct.getDomainId());
  }
  User userExecutingCmd=managementServer.getUser(userId);
  Account acctForUserExecutingCmd=managementServer.findAccountById(Long.valueOf(userExecutingCmd.getAccountId()));
  if ((BaseCmd.isAdmin(acctForUserExecutingCmd.getType()) && (vm.getHostId() != null)) || (BaseCmd.isAdmin(acct.getType()) && (vm.getHostId() != null))) {
    resultObject.setHostname(managementServer.getHostBy(vm.getHostId()).getName());
    resultObject.setHostid(vm.getHostId());
  }
  String templateName="String_Node_Str";
  boolean templatePasswordEnabled=false;
  String templateDisplayText=null;
  if (template != null) {
    templateName=template.getName();
    templatePasswordEnabled=template.getEnablePassword();
    templateDisplayText=template.getDisplayText();
    if (templateDisplayText == null) {
      templateDisplayText=templateName;
    }
  }
  if (templatePasswordEnabled) {
    resultObject.setPassword(param.getPassword());
  }
  Long isoId=vm.getIsoId();
  if (isoId != null) {
    VMTemplateVO iso=getAsyncJobMgr().getExecutorContext().getManagementServer().findTemplateById(isoId.longValue());
    if (iso != null) {
      resultObject.setIsoId(isoId.longValue());
      resultObject.setIsoName(iso.getName());
      resultObject.setTemplateId(isoId.longValue());
      resultObject.setTemplateName(iso.getName());
      templateDisplayText=iso.getDisplayText();
      if (templateDisplayText == null)       templateDisplayText=iso.getName();
      resultObject.setIsoDisplayText(templateDisplayText);
      resultObject.setTemplateDisplayText(templateDisplayText);
    }
  }
 else {
    resultObject.setTemplateId(vm.getTemplateId());
    resultObject.setTemplateName(templateName);
    resultObject.setTemplateDisplayText(templateDisplayText);
    resultObject.setPasswordEnabled(templatePasswordEnabled);
  }
  ServiceOfferingVO offering=managementServer.findServiceOfferingById(vm.getServiceOfferingId());
  resultObject.setServiceOfferingId(vm.getServiceOfferingId());
  resultObject.setServiceOfferingName(offering.getName());
  resultObject.setCpuNumber(String.valueOf(offering.getCpu()));
  resultObject.setCpuSpeed(String.valueOf(offering.getSpeed()));
  resultObject.setMemory(String.valueOf(offering.getRamSize()));
  return resultObject;
}