Program: 107331
Project: 107331
Buggy source:
@Override public <T extends VMInstanceVO>T advanceStart(T vm,Map<String,Object> params,User caller,Account account) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
  State state=vm.getState();
  if (state == State.Starting || state == State.Running) {
    s_logger.debug("String_Node_Str" + vm);
    return vm;
  }
  if (state != State.Stopped) {
    s_logger.debug("String_Node_Str" + vm + "String_Node_Str"+ state);
    return null;
  }
  if (s_logger.isDebugEnabled()) {
    s_logger.debug("String_Node_Str" + vm);
  }
  Journal journal=new Journal.LogJournal("String_Node_Str" + vm,s_logger);
  ItWorkVO work=new ItWorkVO(UUID.randomUUID().toString(),_nodeId,ItWorkVO.Type.Start);
  work=_workDao.persist(work);
  ReservationContextImpl context=new ReservationContextImpl(work.getId(),journal,caller,account);
  ServiceOfferingVO offering=_offeringDao.findById(vm.getServiceOfferingId());
  VMTemplateVO template=_templateDao.findById(vm.getTemplateId());
  DataCenterDeployment plan=new DataCenterDeployment(vm.getDataCenterId(),vm.getPodId(),null,null);
  HypervisorGuru hvGuru=_hvGurus.get(template.getHypervisorType());
  @SuppressWarnings("String_Node_Str") VirtualMachineGuru<T> vmGuru=(VirtualMachineGuru<T>)_vmGurus.get(vm.getType());
  vm.setReservationId(work.getId());
  if (!stateTransitTo(vm,Event.StartRequested,null)) {
    throw new ConcurrentOperationException("String_Node_Str" + vm + "String_Node_Str");
  }
  ExcludeList avoids=new ExcludeList();
  int retry=_retry;
  DeployDestination dest=null;
  while (retry-- != 0) {
    if (retry < (_retry - 1)) {
      stateTransitTo(vm,Event.OperationRetry,dest.getHost().getId());
    }
    VirtualMachineProfileImpl<T> vmProfile=new VirtualMachineProfileImpl<T>(vm,template,offering,null,params);
    for (    DeploymentPlanner planner : _planners) {
      dest=planner.plan(vmProfile,plan,avoids);
      if (dest != null) {
        avoids.addHost(dest.getHost().getId());
        journal.record("String_Node_Str",vmProfile,dest);
        break;
      }
    }
    if (dest == null) {
      stateTransitTo(vm,Event.OperationFailed,null);
      throw new InsufficientServerCapacityException("String_Node_Str" + vmProfile,DataCenter.class,plan.getDataCenterId());
    }
    vm.setDataCenterId(dest.getDataCenter().getId());
    vm.setPodId(dest.getPod().getId());
    try {
      _storageMgr.prepare(vmProfile,dest);
    }
 catch (    ConcurrentOperationException e) {
      stateTransitTo(vm,Event.OperationFailed,dest.getHost().getId());
      throw e;
    }
catch (    StorageUnavailableException e) {
      s_logger.warn("String_Node_Str",e);
      avoids.addCluster(dest.getCluster().getId());
      continue;
    }
    _networkMgr.prepare(vmProfile,dest,context);
    vmGuru.finalizeVirtualMachineProfile(vmProfile,dest,context);
    VirtualMachineTO vmTO=hvGuru.implement(vmProfile);
    Commands cmds=new Commands(OnError.Revert);
    cmds.addCommand(new Start2Command(vmTO));
    vmGuru.finalizeDeployment(cmds,vmProfile,dest,context);
    try {
      Answer[] answers=_agentMgr.send(dest.getHost().getId(),cmds);
      if (answers[0].getResult() && vmGuru.finalizeStart(cmds,vmProfile,dest,context)) {
        if (!stateTransitTo(vm,Event.OperationSucceeded,dest.getHost().getId())) {
          throw new CloudRuntimeException("String_Node_Str");
        }
        return vm;
      }
      s_logger.info("String_Node_Str" + dest.getHost() + "String_Node_Str"+ answers[0].getDetails());
    }
 catch (    AgentUnavailableException e) {
      s_logger.debug("String_Node_Str" + dest.getHost());
      continue;
    }
catch (    OperationTimedoutException e) {
      s_logger.debug("String_Node_Str" + dest.getHost());
      continue;
    }
  }
  stateTransitTo(vm,Event.OperationFailed,dest.getHost().getId());
  if (s_logger.isDebugEnabled()) {
    s_logger.debug("String_Node_Str" + vm);
  }
  return null;
}

Fixed version (ground truth):
@Override public <T extends VMInstanceVO>T advanceStart(T vm,Map<String,Object> params,User caller,Account account,HypervisorType hyperType) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
  State state=vm.getState();
  if (state == State.Starting || state == State.Running) {
    s_logger.debug("String_Node_Str" + vm);
    return vm;
  }
  if (state != State.Stopped) {
    s_logger.debug("String_Node_Str" + vm + "String_Node_Str"+ state);
    return null;
  }
  if (s_logger.isDebugEnabled()) {
    s_logger.debug("String_Node_Str" + vm);
  }
  Journal journal=new Journal.LogJournal("String_Node_Str" + vm,s_logger);
  ItWorkVO work=new ItWorkVO(UUID.randomUUID().toString(),_nodeId,ItWorkVO.Type.Start);
  work=_workDao.persist(work);
  ReservationContextImpl context=new ReservationContextImpl(work.getId(),journal,caller,account);
  ServiceOfferingVO offering=_offeringDao.findById(vm.getServiceOfferingId());
  VMTemplateVO template=_templateDao.findById(vm.getTemplateId());
  DataCenterDeployment plan=new DataCenterDeployment(vm.getDataCenterId(),vm.getPodId(),null,null);
  HypervisorGuru hvGuru;
  if (hyperType != null && !hyperType.equals(HypervisorType.None)) {
    hvGuru=_hvGurus.get(hyperType);
  }
 else {
    hvGuru=_hvGurus.get(template.getHypervisorType());
  }
  @SuppressWarnings("String_Node_Str") VirtualMachineGuru<T> vmGuru=(VirtualMachineGuru<T>)_vmGurus.get(vm.getType());
  vm.setReservationId(work.getId());
  if (!stateTransitTo(vm,Event.StartRequested,null)) {
    throw new ConcurrentOperationException("String_Node_Str" + vm + "String_Node_Str");
  }
  ExcludeList avoids=new ExcludeList();
  int retry=_retry;
  DeployDestination dest=null;
  while (retry-- != 0) {
    if (retry < (_retry - 1)) {
      stateTransitTo(vm,Event.OperationRetry,dest.getHost().getId());
    }
    VirtualMachineProfileImpl<T> vmProfile=new VirtualMachineProfileImpl<T>(vm,template,offering,null,params,hyperType);
    for (    DeploymentPlanner planner : _planners) {
      dest=planner.plan(vmProfile,plan,avoids);
      if (dest != null) {
        avoids.addHost(dest.getHost().getId());
        journal.record("String_Node_Str",vmProfile,dest);
        break;
      }
    }
    if (dest == null) {
      stateTransitTo(vm,Event.OperationFailed,null);
      throw new InsufficientServerCapacityException("String_Node_Str" + vmProfile,DataCenter.class,plan.getDataCenterId());
    }
    vm.setDataCenterId(dest.getDataCenter().getId());
    vm.setPodId(dest.getPod().getId());
    try {
      _storageMgr.prepare(vmProfile,dest);
    }
 catch (    ConcurrentOperationException e) {
      stateTransitTo(vm,Event.OperationFailed,dest.getHost().getId());
      throw e;
    }
catch (    StorageUnavailableException e) {
      s_logger.warn("String_Node_Str",e);
      avoids.addCluster(dest.getCluster().getId());
      continue;
    }
    _networkMgr.prepare(vmProfile,dest,context);
    vmGuru.finalizeVirtualMachineProfile(vmProfile,dest,context);
    VirtualMachineTO vmTO=hvGuru.implement(vmProfile);
    Commands cmds=new Commands(OnError.Revert);
    cmds.addCommand(new Start2Command(vmTO));
    vmGuru.finalizeDeployment(cmds,vmProfile,dest,context);
    try {
      Answer[] answers=_agentMgr.send(dest.getHost().getId(),cmds);
      if (answers[0].getResult() && vmGuru.finalizeStart(cmds,vmProfile,dest,context)) {
        if (!stateTransitTo(vm,Event.OperationSucceeded,dest.getHost().getId())) {
          throw new CloudRuntimeException("String_Node_Str");
        }
        return vm;
      }
      s_logger.info("String_Node_Str" + dest.getHost() + "String_Node_Str"+ answers[0].getDetails());
    }
 catch (    AgentUnavailableException e) {
      s_logger.debug("String_Node_Str" + dest.getHost());
      continue;
    }
catch (    OperationTimedoutException e) {
      s_logger.debug("String_Node_Str" + dest.getHost());
      continue;
    }
  }
  stateTransitTo(vm,Event.OperationFailed,dest.getHost().getId());
  if (s_logger.isDebugEnabled()) {
    s_logger.debug("String_Node_Str" + vm);
  }
  return null;
}