Program: 105697
Project: 105697
Buggy source:
@Override public UserVm destroyVm(long vmId) throws ResourceUnavailableException, ConcurrentOperationException {
  Long userId=2L;
  UserVmVO vm=_vmDao.findById(vmId);
  if (vm == null || vm.getRemoved() != null) {
    InvalidParameterValueException ex=new InvalidParameterValueException("String_Node_Str");
    throw ex;
  }
  if (vm.getState() == State.Destroyed || vm.getState() == State.Expunging) {
    s_logger.trace("String_Node_Str" + vmId + "String_Node_Str");
    return vm;
  }
  User userCaller=_userDao.findById(userId);
  boolean status;
  State vmState=vm.getState();
  try {
    VirtualMachineEntity vmEntity=_orchSrvc.getVirtualMachine(vm.getUuid());
    status=vmEntity.destroy(Long.toString(userId));
  }
 catch (  CloudException e) {
    CloudRuntimeException ex=new CloudRuntimeException("String_Node_Str",e);
    ex.addProxyObject(vm.getUuid(),"String_Node_Str");
    throw ex;
  }
  if (status) {
    List<VolumeVO> volumes=_volsDao.findByInstance(vmId);
    for (    VolumeVO volume : volumes) {
      if (volume.getVolumeType().equals(Volume.Type.ROOT)) {
        UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_DELETE,volume.getAccountId(),volume.getDataCenterId(),volume.getId(),volume.getName(),Volume.class.getName(),volume.getUuid(),volume.isDisplayVolume());
      }
    }
    if (vmState != State.Error) {
      ServiceOfferingVO offering=_serviceOfferingDao.findByIdIncludingRemoved(vm.getId(),vm.getServiceOfferingId());
      resourceCountDecrement(vm.getAccountId(),vm.isDisplayVm(),new Long(offering.getCpu()),new Long(offering.getRamSize()));
    }
    return _vmDao.findById(vmId);
  }
 else {
    CloudRuntimeException ex=new CloudRuntimeException("String_Node_Str");
    ex.addProxyObject(vm.getUuid(),"String_Node_Str");
    throw ex;
  }
}

Fixed version (ground truth):
@Override public UserVm destroyVm(long vmId) throws ResourceUnavailableException, ConcurrentOperationException {
  Long userId=2L;
  UserVmVO vm=_vmDao.findById(vmId);
  if (vm == null || vm.getRemoved() != null) {
    InvalidParameterValueException ex=new InvalidParameterValueException("String_Node_Str");
    throw ex;
  }
  if (vm.getState() == State.Destroyed || vm.getState() == State.Expunging) {
    s_logger.trace("String_Node_Str" + vmId + "String_Node_Str");
    return vm;
  }
  boolean status;
  State vmState=vm.getState();
  try {
    VirtualMachineEntity vmEntity=_orchSrvc.getVirtualMachine(vm.getUuid());
    status=vmEntity.destroy(Long.toString(userId));
  }
 catch (  CloudException e) {
    CloudRuntimeException ex=new CloudRuntimeException("String_Node_Str",e);
    ex.addProxyObject(vm.getUuid(),"String_Node_Str");
    throw ex;
  }
  if (status) {
    List<VolumeVO> volumes=_volsDao.findByInstance(vmId);
    for (    VolumeVO volume : volumes) {
      if (volume.getVolumeType().equals(Volume.Type.ROOT)) {
        UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_DELETE,volume.getAccountId(),volume.getDataCenterId(),volume.getId(),volume.getName(),Volume.class.getName(),volume.getUuid(),volume.isDisplayVolume());
      }
    }
    if (vmState != State.Error) {
      ServiceOfferingVO offering=_serviceOfferingDao.findByIdIncludingRemoved(vm.getId(),vm.getServiceOfferingId());
      resourceCountDecrement(vm.getAccountId(),vm.isDisplayVm(),new Long(offering.getCpu()),new Long(offering.getRamSize()));
    }
    return _vmDao.findById(vmId);
  }
 else {
    CloudRuntimeException ex=new CloudRuntimeException("String_Node_Str");
    ex.addProxyObject(vm.getUuid(),"String_Node_Str");
    throw ex;
  }
}