Program: 107461
Project: 107461
Buggy source:
@Override @DB public VolumeVO allocVolume(long accountId,long userId,String userSpecifiedName,DataCenterVO dc,DiskOfferingVO diskOffering,long startEventId,long size){
  String volumeName="String_Node_Str";
  VolumeVO createdVolume=null;
  try {
    volumeName=getRandomVolumeName();
    Account account=_accountDao.findById(accountId);
    VolumeVO volume=new VolumeVO(userSpecifiedName,-1,-1,-1,-1,new Long(-1),null,null,0,Volume.VolumeType.DATADISK);
    volume.setPoolId(null);
    volume.setDataCenterId(dc.getId());
    volume.setPodId(null);
    volume.setAccountId(accountId);
    volume.setDomainId(account.getDomainId());
    volume.setMirrorState(MirrorState.NOT_MIRRORED);
    volume.setDiskOfferingId(diskOffering.getId());
    volume.setStorageResourceType(Storage.StorageResourceType.STORAGE_POOL);
    volume.setInstanceId(null);
    volume.setUpdated(new Date());
    volume.setStatus(AsyncInstanceCreateStatus.Created);
    volume.setDomainId(account.getDomainId());
    volume.setSourceId(diskOffering.getId());
    volume.setSourceType(SourceType.DiskOffering);
    volume.setState(Volume.State.Allocated);
    volume=_volsDao.persist(volume);
    AsyncJobExecutor asyncExecutor=BaseAsyncJobExecutor.getCurrentExecutor();
    if (asyncExecutor != null) {
      AsyncJobVO job=asyncExecutor.getJob();
      if (s_logger.isInfoEnabled())       s_logger.info("String_Node_Str" + volume.getId() + "String_Node_Str"+ job.getId()+ "String_Node_Str");
      _asyncMgr.updateAsyncJobAttachment(job.getId(),"String_Node_Str",volume.getId());
      _asyncMgr.updateAsyncJobStatus(job.getId(),BaseCmd.PROGRESS_INSTANCE_CREATED,volume.getId());
    }
    createdVolume=volume;
  }
 catch (  Exception e) {
    s_logger.error("String_Node_Str" + volumeName,e);
  }
  return createdVolume;
}

Fixed version (ground truth):
@Override @DB public VolumeVO allocVolume(long accountId,long userId,String userSpecifiedName,DataCenterVO dc,DiskOfferingVO diskOffering,long startEventId,long size){
  String volumeName="String_Node_Str";
  VolumeVO allocatedVolume=null;
  try {
    volumeName=getRandomVolumeName();
    Account account=_accountDao.findById(accountId);
    VolumeVO volume=new VolumeVO(userSpecifiedName,-1,-1,-1,-1,new Long(-1),null,null,0,Volume.VolumeType.DATADISK);
    volume.setPoolId(null);
    volume.setDataCenterId(dc.getId());
    volume.setPodId(null);
    volume.setAccountId(accountId);
    volume.setDomainId(account.getDomainId());
    volume.setMirrorState(MirrorState.NOT_MIRRORED);
    volume.setDiskOfferingId(diskOffering.getId());
    volume.setStorageResourceType(Storage.StorageResourceType.STORAGE_POOL);
    volume.setInstanceId(null);
    volume.setUpdated(new Date());
    volume.setStatus(AsyncInstanceCreateStatus.Created);
    volume.setDomainId(account.getDomainId());
    volume.setSourceId(diskOffering.getId());
    volume.setSourceType(SourceType.DiskOffering);
    volume.setState(Volume.State.Allocated);
    volume=_volsDao.persist(volume);
    allocatedVolume=volume;
    AsyncJobExecutor asyncExecutor=BaseAsyncJobExecutor.getCurrentExecutor();
    if (asyncExecutor != null) {
      AsyncJobVO job=asyncExecutor.getJob();
      if (s_logger.isInfoEnabled())       s_logger.info("String_Node_Str" + volume.getId() + "String_Node_Str"+ job.getId()+ "String_Node_Str");
      _asyncMgr.updateAsyncJobAttachment(job.getId(),"String_Node_Str",volume.getId());
      _asyncMgr.updateAsyncJobStatus(job.getId(),BaseCmd.PROGRESS_INSTANCE_CREATED,volume.getId());
    }
    EventVO event=new EventVO();
    event.setAccountId(accountId);
    event.setType(EventTypes.EVENT_VOLUME_CREATE);
    Transaction txn=Transaction.currentTxn();
    txn.start();
    if (allocatedVolume != null) {
      _accountMgr.incrementResourceCount(accountId,ResourceType.volume);
      long sizeMB=allocatedVolume.getSize() / (1024 * 1024);
      String eventParams="String_Node_Str" + allocatedVolume.getId() + "String_Node_Str"+ diskOffering.getId()+ "String_Node_Str"+ -1+ "String_Node_Str"+ dc.getId()+ "String_Node_Str"+ sizeMB;
      event.setLevel(EventVO.LEVEL_INFO);
      event.setDescription("String_Node_Str" + allocatedVolume.getName() + "String_Node_Str"+ sizeMB+ "String_Node_Str");
      event.setParameters(eventParams);
      _eventDao.persist(event);
    }
 else {
      volume.setStatus(AsyncInstanceCreateStatus.Corrupted);
      volume.setDestroyed(true);
      _volsDao.update(volume.getId(),volume);
    }
    txn.commit();
  }
 catch (  Exception e) {
    s_logger.error("String_Node_Str" + volumeName,e);
  }
  return allocatedVolume;
}