Github user rafaelweingartner commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1956#discussion_r102308166
  
    --- Diff: 
engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java ---
    @@ -744,14 +744,17 @@ protected boolean checkWorkItems(final VMInstanceVO 
vm, final State state) throw
     
         protected <T extends VMInstanceVO> boolean changeState(final T vm, 
final Event event, final Long hostId, final ItWorkVO work, final Step step) 
throws NoTransitionException {
             // FIXME: We should do this better.
    -        final Step previousStep = work.getStep();
    -        _workDao.updateStep(work, step);
    +        Step previousStep = null;
    +        if (work != null) {
    +            previousStep = work.getStep();
    --- End diff --
    
    I am not asking to make a distinction between exception or not. What I 
tried to say is that, if the intent/purpose of the `finally` block was only to 
revert the step to a previous state when exceptions occur, we could do that 
using a `catch` block. I think the finally here is meant to revert the state of 
work step even if an exception does not happen, for instance when ` 
stateTransitTo ` returns `false`.
    
    I think you already answered my doubt; when you said that the ` 
previousStep ` is most likely never to be `null`. I thought we could have cases 
where ` previousStep == null`, and then if the ` stateTransitTo` returns false, 
with the newly added check at line 757, we would not update the step back to 
`null` for these cases.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to