Program: 89733
Project: 89733
Buggy source:
@Override @ActionEvent(eventType=EventTypes.EVENT_VM_UPGRADE,eventDescription="String_Node_Str") public UserVm upgradeVirtualMachine(UpgradeVMCmd cmd){
  Long virtualMachineId=cmd.getId();
  Long serviceOfferingId=cmd.getServiceOfferingId();
  Account account=UserContext.current().getCaller();
  Long userId=UserContext.current().getCallerUserId();
  UserVmVO vmInstance=_vmDao.findById(virtualMachineId);
  if (vmInstance == null) {
    throw new InvalidParameterValueException("String_Node_Str" + virtualMachineId);
  }
  userId=accountAndUserValidation(virtualMachineId,account,userId,vmInstance);
  ServiceOfferingVO newServiceOffering=_offeringDao.findById(serviceOfferingId);
  if (newServiceOffering == null) {
    throw new InvalidParameterValueException("String_Node_Str" + serviceOfferingId);
  }
  if (!(vmInstance.getState().equals(State.Stopped) || vmInstance.getState().equals(State.Running))) {
    s_logger.warn("String_Node_Str" + vmInstance.toString() + "String_Node_Str"+ vmInstance.getState());
    throw new InvalidParameterValueException("String_Node_Str" + vmInstance.toString() + "String_Node_Str"+ vmInstance.getState()+ "String_Node_Str");
  }
  if (vmInstance.getServiceOfferingId() == newServiceOffering.getId()) {
    if (s_logger.isInfoEnabled()) {
      s_logger.info("String_Node_Str" + vmInstance.toString() + "String_Node_Str"+ newServiceOffering.getName()+ "String_Node_Str");
    }
    throw new InvalidParameterValueException("String_Node_Str" + vmInstance.toString() + "String_Node_Str"+ newServiceOffering.getName()+ "String_Node_Str");
  }
  ServiceOfferingVO currentServiceOffering=_offeringDao.findById(vmInstance.getServiceOfferingId());
  if (currentServiceOffering.getUseLocalStorage() != newServiceOffering.getUseLocalStorage()) {
    throw new InvalidParameterValueException("String_Node_Str" + vmInstance.toString() + "String_Node_Str"+ currentServiceOffering.getUseLocalStorage()+ "String_Node_Str"+ newServiceOffering.getUseLocalStorage());
  }
  if (!_agentMgr.isVirtualMachineUpgradable(vmInstance,newServiceOffering)) {
    throw new InvalidParameterValueException("String_Node_Str" + newServiceOffering.getCpu() + "String_Node_Str"+ newServiceOffering.getSpeed()+ "String_Node_Str"+ newServiceOffering.getRamSize()+ "String_Node_Str");
  }
  List<String> currentTags=_configMgr.csvTagsToList(currentServiceOffering.getTags());
  List<String> newTags=_configMgr.csvTagsToList(newServiceOffering.getTags());
  if (!newTags.containsAll(currentTags)) {
    throw new InvalidParameterValueException("String_Node_Str" + "String_Node_Str" + currentTags + "String_Node_Str"+ "String_Node_Str"+ newTags);
  }
  UserVmVO vmForUpdate=_vmDao.createForUpdate();
  vmForUpdate.setServiceOfferingId(serviceOfferingId);
  vmForUpdate.setHaEnabled(_serviceOfferingDao.findById(serviceOfferingId).getOfferHA());
  _vmDao.update(vmInstance.getId(),vmForUpdate);
  return _vmDao.findById(vmInstance.getId());
}

Fixed version (ground truth):
@Override @ActionEvent(eventType=EventTypes.EVENT_VM_UPGRADE,eventDescription="String_Node_Str") public UserVm upgradeVirtualMachine(UpgradeVMCmd cmd){
  Long virtualMachineId=cmd.getId();
  Long serviceOfferingId=cmd.getServiceOfferingId();
  Account account=UserContext.current().getCaller();
  Long userId=UserContext.current().getCallerUserId();
  UserVmVO vmInstance=_vmDao.findById(virtualMachineId);
  if (vmInstance == null) {
    throw new InvalidParameterValueException("String_Node_Str" + virtualMachineId);
  }
  userId=accountAndUserValidation(virtualMachineId,account,userId,vmInstance);
  ServiceOfferingVO newServiceOffering=_offeringDao.findById(serviceOfferingId);
  if (newServiceOffering == null) {
    throw new InvalidParameterValueException("String_Node_Str" + serviceOfferingId);
  }
  if (!(vmInstance.getState().equals(State.Stopped) || vmInstance.getState().equals(State.Running))) {
    s_logger.warn("String_Node_Str" + vmInstance.toString() + "String_Node_Str"+ vmInstance.getState());
    throw new InvalidParameterValueException("String_Node_Str" + vmInstance.toString() + "String_Node_Str"+ vmInstance.getState()+ "String_Node_Str");
  }
  if (vmInstance.getServiceOfferingId() == newServiceOffering.getId()) {
    if (s_logger.isInfoEnabled()) {
      s_logger.info("String_Node_Str" + vmInstance.toString() + "String_Node_Str"+ newServiceOffering.getName()+ "String_Node_Str");
    }
    throw new InvalidParameterValueException("String_Node_Str" + vmInstance.toString() + "String_Node_Str"+ newServiceOffering.getName()+ "String_Node_Str");
  }
  ServiceOfferingVO currentServiceOffering=_offeringDao.findByIdIncludingRemoved(vmInstance.getServiceOfferingId());
  if (currentServiceOffering.getUseLocalStorage() != newServiceOffering.getUseLocalStorage()) {
    throw new InvalidParameterValueException("String_Node_Str" + vmInstance.toString() + "String_Node_Str"+ currentServiceOffering.getUseLocalStorage()+ "String_Node_Str"+ newServiceOffering.getUseLocalStorage());
  }
  if (!_agentMgr.isVirtualMachineUpgradable(vmInstance,newServiceOffering)) {
    throw new InvalidParameterValueException("String_Node_Str" + newServiceOffering.getCpu() + "String_Node_Str"+ newServiceOffering.getSpeed()+ "String_Node_Str"+ newServiceOffering.getRamSize()+ "String_Node_Str");
  }
  List<String> currentTags=_configMgr.csvTagsToList(currentServiceOffering.getTags());
  List<String> newTags=_configMgr.csvTagsToList(newServiceOffering.getTags());
  if (!newTags.containsAll(currentTags)) {
    throw new InvalidParameterValueException("String_Node_Str" + "String_Node_Str" + currentTags + "String_Node_Str"+ "String_Node_Str"+ newTags);
  }
  UserVmVO vmForUpdate=_vmDao.createForUpdate();
  vmForUpdate.setServiceOfferingId(serviceOfferingId);
  vmForUpdate.setHaEnabled(_serviceOfferingDao.findById(serviceOfferingId).getOfferHA());
  _vmDao.update(vmInstance.getId(),vmForUpdate);
  return _vmDao.findById(vmInstance.getId());
}