Program: 89394
Project: 89394
Buggy source:
@Override public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<UserVmVO> profile,DeployDestination dest,ReservationContext context){
  UserVmVO vm=profile.getVirtualMachine();
  Account owner=_accountDao.findById(vm.getAccountId());
  if (owner == null) {
    throw new PermissionDeniedException("String_Node_Str" + vm + "String_Node_Str"+ vm.getAccountId());
  }
  if (owner.getState() == Account.State.disabled) {
    throw new PermissionDeniedException("String_Node_Str" + vm + "String_Node_Str"+ vm.getAccountId());
  }
  VirtualMachineTemplate template=profile.getTemplate();
  if (vm.getIsoId() != null) {
    template=_templateDao.findById(vm.getIsoId());
  }
  if (template != null && template.getFormat() == ImageFormat.ISO && vm.getIsoId() != null) {
    String isoPath=null;
    Pair<String,String> isoPathPair=_storageMgr.getAbsoluteIsoPath(template.getId(),vm.getDataCenterIdToDeployIn());
    if (isoPathPair == null) {
      s_logger.warn("String_Node_Str");
      return false;
    }
 else {
      isoPath=isoPathPair.first();
    }
    if (template.isBootable()) {
      profile.setBootLoaderType(BootloaderType.CD);
    }
    GuestOSVO guestOS=_guestOSDao.findById(template.getGuestOSId());
    String displayName=null;
    if (guestOS != null) {
      displayName=guestOS.getDisplayName();
    }
    VolumeTO iso=new VolumeTO(profile.getId(),Volume.Type.ISO,StoragePoolType.ISO,null,template.getName(),null,isoPath,0,null,displayName);
    iso.setDeviceId(3);
    profile.addDisk(iso);
  }
 else {
    VolumeTO iso=new VolumeTO(profile.getId(),Volume.Type.ISO,StoragePoolType.ISO,null,template.getName(),null,null,0,null);
    iso.setDeviceId(3);
    profile.addDisk(iso);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<UserVmVO> profile,DeployDestination dest,ReservationContext context){
  UserVmVO vm=profile.getVirtualMachine();
  Map<String,String> details=_vmDetailsDao.findDetails(vm.getId());
  vm.setDetails(details);
  Account owner=_accountDao.findById(vm.getAccountId());
  if (owner == null) {
    throw new PermissionDeniedException("String_Node_Str" + vm + "String_Node_Str"+ vm.getAccountId());
  }
  if (owner.getState() == Account.State.disabled) {
    throw new PermissionDeniedException("String_Node_Str" + vm + "String_Node_Str"+ vm.getAccountId());
  }
  VirtualMachineTemplate template=profile.getTemplate();
  if (vm.getIsoId() != null) {
    template=_templateDao.findById(vm.getIsoId());
  }
  if (template != null && template.getFormat() == ImageFormat.ISO && vm.getIsoId() != null) {
    String isoPath=null;
    Pair<String,String> isoPathPair=_storageMgr.getAbsoluteIsoPath(template.getId(),vm.getDataCenterIdToDeployIn());
    if (isoPathPair == null) {
      s_logger.warn("String_Node_Str");
      return false;
    }
 else {
      isoPath=isoPathPair.first();
    }
    if (template.isBootable()) {
      profile.setBootLoaderType(BootloaderType.CD);
    }
    GuestOSVO guestOS=_guestOSDao.findById(template.getGuestOSId());
    String displayName=null;
    if (guestOS != null) {
      displayName=guestOS.getDisplayName();
    }
    VolumeTO iso=new VolumeTO(profile.getId(),Volume.Type.ISO,StoragePoolType.ISO,null,template.getName(),null,isoPath,0,null,displayName);
    iso.setDeviceId(3);
    profile.addDisk(iso);
  }
 else {
    VolumeTO iso=new VolumeTO(profile.getId(),Volume.Type.ISO,StoragePoolType.ISO,null,template.getName(),null,null,0,null);
    iso.setDeviceId(3);
    profile.addDisk(iso);
  }
  return true;
}