Program: 105852
Project: 105852
Buggy source:
@DB protected Void createVolumeFromBaseImageCallBack(AsyncCallbackDispatcher<VolumeServiceImpl,CopyCommandResult> callback,CreateVolumeFromBaseImageContext<VolumeApiResult> context){
  DataObject vo=context.vo;
  DataObject tmplOnPrimary=context.templateOnStore;
  CopyCommandResult result=callback.getResult();
  VolumeApiResult volResult=new VolumeApiResult((VolumeObject)vo);
  if (result.isSuccess()) {
    vo.processEvent(Event.OperationSuccessed,result.getAnswer());
  }
 else {
    vo.processEvent(Event.OperationFailed);
    volResult.setResult(result.getResult());
    Answer ans=result.getAnswer();
    if (ans != null && ans instanceof CopyCmdAnswer && ans.getDetails().contains("String_Node_Str")) {
      if (tmplOnPrimary != null) {
        s_logger.info("String_Node_Str");
        VMTemplateStoragePoolVO templatePoolRef=_tmpltPoolDao.findByPoolTemplate(tmplOnPrimary.getDataStore().getId(),tmplOnPrimary.getId());
        if (templatePoolRef != null) {
          long templatePoolRefId=templatePoolRef.getId();
          templatePoolRef=_tmpltPoolDao.acquireInLockTable(templatePoolRefId,1200);
          if (templatePoolRef == null) {
            s_logger.warn("String_Node_Str" + templatePoolRefId);
          }
          try {
            templatePoolRef.setDownloadState(VMTemplateStorageResourceAssoc.Status.NOT_DOWNLOADED);
            templatePoolRef.setState(ObjectInDataStoreStateMachine.State.Allocated);
            _tmpltPoolDao.update(templatePoolRefId,templatePoolRef);
          }
  finally {
            _tmpltPoolDao.releaseFromLockTable(templatePoolRefId);
          }
        }
      }
    }
  }
  AsyncCallFuture<VolumeApiResult> future=context.getFuture();
  future.complete(volResult);
  return null;
}

Fixed version (ground truth):
@DB protected Void createVolumeFromBaseImageCallBack(AsyncCallbackDispatcher<VolumeServiceImpl,CopyCommandResult> callback,CreateVolumeFromBaseImageContext<VolumeApiResult> context){
  DataObject vo=context.vo;
  DataObject tmplOnPrimary=context.templateOnStore;
  CopyCommandResult result=callback.getResult();
  VolumeApiResult volResult=new VolumeApiResult((VolumeObject)vo);
  if (result.isSuccess()) {
    vo.processEvent(Event.OperationSuccessed,result.getAnswer());
  }
 else {
    vo.processEvent(Event.OperationFailed);
    volResult.setResult(result.getResult());
    Answer ans=result.getAnswer();
    if (ans != null && ans instanceof CopyCmdAnswer && ans.getDetails().contains("String_Node_Str")) {
      if (tmplOnPrimary != null) {
        s_logger.info("String_Node_Str");
        VMTemplateStoragePoolVO templatePoolRef=_tmpltPoolDao.findByPoolTemplate(tmplOnPrimary.getDataStore().getId(),tmplOnPrimary.getId());
        if (templatePoolRef != null) {
          long templatePoolRefId=templatePoolRef.getId();
          templatePoolRef=_tmpltPoolDao.acquireInLockTable(templatePoolRefId,1200);
          try {
            if (templatePoolRef == null) {
              s_logger.warn("String_Node_Str" + templatePoolRefId);
            }
 else {
              templatePoolRef.setDownloadState(VMTemplateStorageResourceAssoc.Status.NOT_DOWNLOADED);
              templatePoolRef.setState(ObjectInDataStoreStateMachine.State.Allocated);
              _tmpltPoolDao.update(templatePoolRefId,templatePoolRef);
            }
          }
  finally {
            _tmpltPoolDao.releaseFromLockTable(templatePoolRefId);
          }
        }
      }
    }
  }
  AsyncCallFuture<VolumeApiResult> future=context.getFuture();
  future.complete(volResult);
  return null;
}