Program: 107321
Project: 107321
Buggy source:
protected Map<String,Object> createSecStorageVmInstance2(long dataCenterId){
  long startEventId=saveStartedEvent(User.UID_SYSTEM,Account.ACCOUNT_ID_SYSTEM,EventTypes.EVENT_SSVM_CREATE,"String_Node_Str" + dataCenterId,0);
  HostVO secHost=_hostDao.findSecondaryStorageHost(dataCenterId);
  if (secHost == null) {
    String msg="String_Node_Str" + dataCenterId + "String_Node_Str";
    s_logger.warn(msg);
    saveFailedEvent(User.UID_SYSTEM,Account.ACCOUNT_ID_SYSTEM,EventTypes.EVENT_SSVM_CREATE,msg,startEventId);
    throw new CloudRuntimeException(msg);
  }
  _secHostUuid=secHost.getGuid();
  _nfsShare=secHost.getStorageUrl();
  long id=_secStorageVmDao.getNextInSequence(Long.class,"String_Node_Str");
  String name=VirtualMachineName.getSystemVmName(id,_instance,"String_Node_Str").intern();
  Account systemAcct=_accountMgr.getSystemAccount();
  DataCenterDeployment plan=new DataCenterDeployment(dataCenterId);
  List<NetworkOfferingVO> defaultOffering=_networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmPublicNetwork);
  List<NetworkOfferingVO> offerings=_networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmControlNetwork,NetworkOfferingVO.SystemVmManagementNetwork);
  List<Pair<NetworkVO,NicProfile>> networks=new ArrayList<Pair<NetworkVO,NicProfile>>(offerings.size() + 1);
  NicProfile defaultNic=new NicProfile();
  defaultNic.setDefaultNic(true);
  defaultNic.setDeviceId(2);
  try {
    networks.add(new Pair<NetworkVO,NicProfile>(_networkMgr.setupNetwork(systemAcct,defaultOffering.get(0),plan,null,null,false).get(0),defaultNic));
    for (    NetworkOfferingVO offering : offerings) {
      networks.add(new Pair<NetworkVO,NicProfile>(_networkMgr.setupNetwork(systemAcct,offering,plan,null,null,false).get(0),null));
    }
  }
 catch (  ConcurrentOperationException e) {
    s_logger.info("String_Node_Str" + e);
    return new HashMap<String,Object>();
  }
  SecondaryStorageVmVO secStorageVm=new SecondaryStorageVmVO(id,_serviceOffering.getId(),name,_template.getId(),_template.getGuestOSId(),dataCenterId,systemAcct.getDomainId(),systemAcct.getId());
  try {
    secStorageVm=_itMgr.allocate(secStorageVm,_template,_serviceOffering,networks,plan,systemAcct);
  }
 catch (  InsufficientCapacityException e) {
    s_logger.warn("String_Node_Str",e);
    throw new CloudRuntimeException("String_Node_Str",e);
  }
catch (  ResourceUnavailableException e) {
    s_logger.warn("String_Node_Str",e);
    throw new CloudRuntimeException("String_Node_Str",e);
  }
  Map<String,Object> context=new HashMap<String,Object>();
  context.put("String_Node_Str",secStorageVm.getId());
  return context;
}

Fixed version (ground truth):
protected Map<String,Object> createSecStorageVmInstance2(long dataCenterId){
  long startEventId=saveStartedEvent(User.UID_SYSTEM,Account.ACCOUNT_ID_SYSTEM,EventTypes.EVENT_SSVM_CREATE,"String_Node_Str" + dataCenterId,0);
  HostVO secHost=_hostDao.findSecondaryStorageHost(dataCenterId);
  if (secHost == null) {
    String msg="String_Node_Str" + dataCenterId + "String_Node_Str";
    s_logger.warn(msg);
    saveFailedEvent(User.UID_SYSTEM,Account.ACCOUNT_ID_SYSTEM,EventTypes.EVENT_SSVM_CREATE,msg,startEventId);
    throw new CloudRuntimeException(msg);
  }
  _secHostUuid=secHost.getGuid();
  _nfsShare=secHost.getStorageUrl();
  long id=_secStorageVmDao.getNextInSequence(Long.class,"String_Node_Str");
  String name=VirtualMachineName.getSystemVmName(id,_instance,"String_Node_Str").intern();
  Account systemAcct=_accountMgr.getSystemAccount();
  DataCenterDeployment plan=new DataCenterDeployment(dataCenterId);
  List<NetworkOfferingVO> defaultOffering=_networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmPublicNetwork);
  List<NetworkOfferingVO> offerings=_networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmControlNetwork,NetworkOfferingVO.SystemVmManagementNetwork);
  List<Pair<NetworkVO,NicProfile>> networks=new ArrayList<Pair<NetworkVO,NicProfile>>(offerings.size() + 1);
  NicProfile defaultNic=new NicProfile();
  defaultNic.setDefaultNic(true);
  defaultNic.setDeviceId(2);
  try {
    networks.add(new Pair<NetworkVO,NicProfile>(_networkMgr.setupNetwork(systemAcct,defaultOffering.get(0),plan,null,null,false).get(0),defaultNic));
    for (    NetworkOfferingVO offering : offerings) {
      networks.add(new Pair<NetworkVO,NicProfile>(_networkMgr.setupNetwork(systemAcct,offering,plan,null,null,false).get(0),null));
    }
  }
 catch (  ConcurrentOperationException e) {
    s_logger.info("String_Node_Str" + e);
    return new HashMap<String,Object>();
  }
  SecondaryStorageVmVO secStorageVm=new SecondaryStorageVmVO(id,_serviceOffering.getId(),name,_template.getId(),_template.getGuestOSId(),dataCenterId,systemAcct.getDomainId(),systemAcct.getId());
  try {
    secStorageVm=_itMgr.allocate(secStorageVm,_template,_serviceOffering,networks,plan,null,systemAcct);
  }
 catch (  InsufficientCapacityException e) {
    s_logger.warn("String_Node_Str",e);
    throw new CloudRuntimeException("String_Node_Str",e);
  }
catch (  ResourceUnavailableException e) {
    s_logger.warn("String_Node_Str",e);
    throw new CloudRuntimeException("String_Node_Str",e);
  }
  Map<String,Object> context=new HashMap<String,Object>();
  context.put("String_Node_Str",secStorageVm.getId());
  return context;
}