Program: 89545
Project: 89545
Buggy source:
@DB protected <T extends VMInstanceVO>Ternary<T,ReservationContext,ItWorkVO> changeToStartState(VirtualMachineGuru<T> vmGuru,T vm,User caller,Account account) throws ConcurrentOperationException {
  long vmId=vm.getId();
  ItWorkVO work=new ItWorkVO(UUID.randomUUID().toString(),_nodeId,State.Starting,vm.getType(),vm.getId());
  int retry=_lockStateRetry;
  while (retry-- != 0) {
    Transaction txn=Transaction.currentTxn();
    txn.start();
    try {
      if (stateTransitTo(vm,Event.StartRequested,null,work.getId())) {
        Journal journal=new Journal.LogJournal("String_Node_Str" + vm,s_logger);
        work=_workDao.persist(work);
        ReservationContextImpl context=new ReservationContextImpl(work.getId(),journal,caller,account);
        if (s_logger.isDebugEnabled()) {
          s_logger.debug("String_Node_Str" + vm + "String_Node_Str"+ work.getId());
        }
        Ternary<T,ReservationContext,ItWorkVO> result=new Ternary<T,ReservationContext,ItWorkVO>(vmGuru.findById(vmId),context,work);
        txn.commit();
        return result;
      }
    }
 catch (    NoTransitionException e) {
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str" + e.getMessage());
      }
    }
    VMInstanceVO instance=_vmDao.findById(vmId);
    if (instance == null) {
      throw new ConcurrentOperationException("String_Node_Str" + vm);
    }
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str" + instance + "String_Node_Str"+ retry);
    }
    State state=instance.getState();
    if (state == State.Running) {
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str" + vm);
      }
      return null;
    }
    if (state.isTransitional()) {
      if (!checkWorkItems(vm,state)) {
        throw new ConcurrentOperationException("String_Node_Str" + vm);
      }
 else {
        continue;
      }
    }
    if (state != State.Stopped) {
      s_logger.debug("String_Node_Str" + vm + "String_Node_Str"+ state);
      return null;
    }
  }
  throw new ConcurrentOperationException("String_Node_Str" + vm);
}

Fixed version (ground truth):
protected <T extends VMInstanceVO>Ternary<T,ReservationContext,ItWorkVO> changeToStartState(VirtualMachineGuru<T> vmGuru,T vm,User caller,Account account) throws ConcurrentOperationException {
  long vmId=vm.getId();
  ItWorkVO work=new ItWorkVO(UUID.randomUUID().toString(),_nodeId,State.Starting,vm.getType(),vm.getId());
  int retry=_lockStateRetry;
  while (retry-- != 0) {
    Transaction txn=Transaction.currentTxn();
    Ternary<T,ReservationContext,ItWorkVO> result=null;
    txn.start();
    try {
      Journal journal=new Journal.LogJournal("String_Node_Str" + vm,s_logger);
      work=_workDao.persist(work);
      ReservationContextImpl context=new ReservationContextImpl(work.getId(),journal,caller,account);
      if (stateTransitTo(vm,Event.StartRequested,null,work.getId())) {
        if (s_logger.isDebugEnabled()) {
          s_logger.debug("String_Node_Str" + vm + "String_Node_Str"+ work.getId());
        }
        result=new Ternary<T,ReservationContext,ItWorkVO>(vmGuru.findById(vmId),context,work);
        txn.commit();
        return result;
      }
    }
 catch (    NoTransitionException e) {
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str" + e.getMessage());
      }
    }
 finally {
      if (result == null) {
        txn.rollback();
      }
    }
    VMInstanceVO instance=_vmDao.findById(vmId);
    if (instance == null) {
      throw new ConcurrentOperationException("String_Node_Str" + vm);
    }
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str" + instance + "String_Node_Str"+ retry);
    }
    State state=instance.getState();
    if (state == State.Running) {
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str" + vm);
      }
      return null;
    }
    if (state.isTransitional()) {
      if (!checkWorkItems(vm,state)) {
        throw new ConcurrentOperationException("String_Node_Str" + vm);
      }
 else {
        continue;
      }
    }
    if (state != State.Stopped) {
      s_logger.debug("String_Node_Str" + vm + "String_Node_Str"+ state);
      return null;
    }
  }
  throw new ConcurrentOperationException("String_Node_Str" + vm);
}