Program: 106263
Project: 106263
Buggy source:
@DB @Override public DataStore createLocalStorage(Host host,StoragePoolInfo pInfo) throws ConnectionException {
  DataCenterVO dc=_dcDao.findById(host.getDataCenterId());
  if (dc == null || !dc.isLocalStorageEnabled()) {
    return null;
  }
  DataStore store=null;
  try {
    StoragePoolVO pool=_storagePoolDao.findPoolByHostPath(host.getDataCenterId(),host.getPodId(),pInfo.getHost(),pInfo.getHostPath(),pInfo.getUuid());
    if (pool == null && host.getHypervisorType() == HypervisorType.VMware) {
      if (pInfo.getHostPath().length() > 0) {
        pool=_storagePoolDao.findPoolByHostPath(host.getDataCenterId(),host.getPodId(),pInfo.getHost(),"String_Node_Str",pInfo.getUuid());
      }
    }
    DataStoreProvider provider=this.dataStoreProviderMgr.getDefaultPrimaryDataStoreProvider();
    DataStoreLifeCycle lifeCycle=provider.getDataStoreLifeCycle();
    if (pool == null) {
      Map<String,Object> params=new HashMap<String,Object>();
      String name=(host.getName() + "String_Node_Str");
      params.put("String_Node_Str",host.getDataCenterId());
      params.put("String_Node_Str",host.getClusterId());
      params.put("String_Node_Str",host.getPodId());
      params.put("String_Node_Str",pInfo.getPoolType().toString() + "String_Node_Str" + pInfo.getHost()+ "String_Node_Str"+ pInfo.getHostPath());
      params.put("String_Node_Str",name);
      params.put("String_Node_Str",true);
      params.put("String_Node_Str",pInfo.getDetails());
      params.put("String_Node_Str",pInfo.getUuid());
      params.put("String_Node_Str",provider.getName());
      store=lifeCycle.initialize(params);
    }
 else {
      store=(DataStore)dataStoreMgr.getDataStore(pool.getId(),DataStoreRole.Primary);
    }
    HostScope scope=new HostScope(host.getId());
    lifeCycle.attachHost(store,scope,pInfo);
  }
 catch (  Exception e) {
    s_logger.warn("String_Node_Str" + host,e);
    throw new ConnectionException(true,"String_Node_Str" + host,e);
  }
  return (DataStore)dataStoreMgr.getDataStore(store.getId(),DataStoreRole.Primary);
}

Fixed version (ground truth):
@DB @Override public DataStore createLocalStorage(Host host,StoragePoolInfo pInfo) throws ConnectionException {
  DataCenterVO dc=_dcDao.findById(host.getDataCenterId());
  if (dc == null || !dc.isLocalStorageEnabled()) {
    return null;
  }
  DataStore store=null;
  try {
    StoragePoolVO pool=_storagePoolDao.findPoolByHostPath(host.getDataCenterId(),host.getPodId(),pInfo.getHost(),pInfo.getHostPath(),pInfo.getUuid());
    if (pool == null && host.getHypervisorType() == HypervisorType.VMware) {
      if (pInfo.getHostPath().length() > 0) {
        pool=_storagePoolDao.findPoolByHostPath(host.getDataCenterId(),host.getPodId(),pInfo.getHost(),"String_Node_Str",pInfo.getUuid());
      }
    }
    DataStoreProvider provider=this.dataStoreProviderMgr.getDefaultPrimaryDataStoreProvider();
    DataStoreLifeCycle lifeCycle=provider.getDataStoreLifeCycle();
    if (pool == null) {
      Map<String,Object> params=new HashMap<String,Object>();
      String name=(host.getName() + "String_Node_Str");
      params.put("String_Node_Str",host.getDataCenterId());
      params.put("String_Node_Str",host.getClusterId());
      params.put("String_Node_Str",host.getPodId());
      params.put("String_Node_Str",pInfo.getPoolType().toString() + "String_Node_Str" + pInfo.getHost()+ "String_Node_Str"+ pInfo.getHostPath());
      params.put("String_Node_Str",name);
      params.put("String_Node_Str",true);
      params.put("String_Node_Str",pInfo.getDetails());
      params.put("String_Node_Str",pInfo.getUuid());
      params.put("String_Node_Str",provider.getName());
      store=lifeCycle.initialize(params);
    }
 else {
      store=(DataStore)dataStoreMgr.getDataStore(pool.getId(),DataStoreRole.Primary);
    }
    HostScope scope=new HostScope(host.getId(),pool.getDataCenterId());
    lifeCycle.attachHost(store,scope,pInfo);
  }
 catch (  Exception e) {
    s_logger.warn("String_Node_Str" + host,e);
    throw new ConnectionException(true,"String_Node_Str" + host,e);
  }
  return (DataStore)dataStoreMgr.getDataStore(store.getId(),DataStoreRole.Primary);
}