Program: 89608
Project: 89608
Buggy source:
@Override @DB public List<NetworkVO> setupNetwork(Account owner,NetworkOfferingVO offering,Network predefined,DeploymentPlan plan,String name,String displayText,boolean isShared,boolean isDefault,boolean errorIfAlreadySetup,Long domainId,List<String> tags) throws ConcurrentOperationException {
  Account locked=_accountDao.acquireInLockTable(owner.getId());
  if (locked == null) {
    throw new ConcurrentOperationException("String_Node_Str" + owner);
  }
  try {
    if (predefined == null || (predefined.getCidr() == null && predefined.getBroadcastUri() == null && predefined.getBroadcastDomainType() != BroadcastDomainType.Vlan)) {
      List<NetworkVO> configs=_networksDao.listBy(owner.getId(),offering.getId(),plan.getDataCenterId());
      if (configs.size() > 0) {
        if (s_logger.isDebugEnabled()) {
          s_logger.debug("String_Node_Str" + offering + "String_Node_Str"+ configs.get(0));
        }
        if (errorIfAlreadySetup) {
          throw new InvalidParameterValueException("String_Node_Str" + offering + "String_Node_Str"+ configs.get(0));
        }
 else {
          return configs;
        }
      }
    }
 else     if (predefined != null && predefined.getCidr() != null && predefined.getBroadcastUri() == null && predefined.getBroadcastUri() == null) {
      List<NetworkVO> configs=_networksDao.listBy(owner.getId(),offering.getId(),plan.getDataCenterId(),predefined.getCidr());
      if (configs.size() > 0) {
        if (s_logger.isDebugEnabled()) {
          s_logger.debug("String_Node_Str" + offering + "String_Node_Str"+ configs.get(0));
        }
        if (errorIfAlreadySetup) {
          throw new InvalidParameterValueException("String_Node_Str" + offering + "String_Node_Str"+ configs.get(0));
        }
 else {
          return configs;
        }
      }
    }
    List<NetworkVO> networks=new ArrayList<NetworkVO>();
    long related=-1;
    for (    NetworkGuru guru : _networkGurus) {
      Network network=guru.design(offering,plan,predefined,owner);
      if (network == null) {
        continue;
      }
      if (network.getId() != -1) {
        if (network instanceof NetworkVO) {
          networks.add((NetworkVO)network);
        }
 else {
          networks.add(_networksDao.findById(network.getId()));
        }
        continue;
      }
      long id=_networksDao.getNextInSequence(Long.class,"String_Node_Str");
      if (related == -1) {
        related=id;
      }
      NetworkVO vo=new NetworkVO(id,network,offering.getId(),plan.getDataCenterId(),guru.getName(),owner.getDomainId(),owner.getId(),related,name,displayText,isShared,isDefault,predefined.isSecurityGroupEnabled(),(domainId != null));
      vo.setTags(tags);
      networks.add(_networksDao.persist(vo,vo.getGuestType() != null));
      if (domainId != null) {
        _networksDao.addDomainToNetwork(id,domainId);
      }
    }
    if (networks.size() < 1) {
      throw new CloudRuntimeException("String_Node_Str" + offering.getId());
    }
    return networks;
  }
  finally {
    s_logger.debug("String_Node_Str" + locked);
    _accountDao.releaseFromLockTable(locked.getId());
  }
}

Fixed version (ground truth):
@Override @DB public List<NetworkVO> setupNetwork(Account owner,NetworkOfferingVO offering,Network predefined,DeploymentPlan plan,String name,String displayText,boolean isShared,boolean isDefault,boolean errorIfAlreadySetup,Long domainId,List<String> tags) throws ConcurrentOperationException {
  Account locked=_accountDao.acquireInLockTable(owner.getId());
  if (locked == null) {
    throw new ConcurrentOperationException("String_Node_Str" + owner);
  }
  try {
    if (predefined == null || (predefined.getCidr() == null && predefined.getBroadcastUri() == null && predefined.getBroadcastDomainType() != BroadcastDomainType.Vlan)) {
      List<NetworkVO> configs=_networksDao.listBy(owner.getId(),offering.getId(),plan.getDataCenterId());
      if (configs.size() > 0) {
        if (s_logger.isDebugEnabled()) {
          s_logger.debug("String_Node_Str" + offering + "String_Node_Str"+ configs.get(0));
        }
        if (errorIfAlreadySetup) {
          throw new InvalidParameterValueException("String_Node_Str" + offering + "String_Node_Str"+ configs.get(0));
        }
 else {
          return configs;
        }
      }
    }
 else     if (predefined != null && predefined.getCidr() != null && predefined.getBroadcastUri() == null && predefined.getBroadcastUri() == null) {
      List<NetworkVO> configs=_networksDao.listBy(owner.getId(),offering.getId(),plan.getDataCenterId(),predefined.getCidr());
      if (configs.size() > 0) {
        if (s_logger.isDebugEnabled()) {
          s_logger.debug("String_Node_Str" + offering + "String_Node_Str"+ configs.get(0));
        }
        if (errorIfAlreadySetup) {
          throw new InvalidParameterValueException("String_Node_Str" + offering + "String_Node_Str"+ configs.get(0));
        }
 else {
          return configs;
        }
      }
    }
    List<NetworkVO> networks=new ArrayList<NetworkVO>();
    long related=-1;
    for (    NetworkGuru guru : _networkGurus) {
      Network network=guru.design(offering,plan,predefined,owner);
      if (network == null) {
        continue;
      }
      if (network.getId() != -1) {
        if (network instanceof NetworkVO) {
          networks.add((NetworkVO)network);
        }
 else {
          networks.add(_networksDao.findById(network.getId()));
        }
        continue;
      }
      long id=_networksDao.getNextInSequence(Long.class,"String_Node_Str");
      if (related == -1) {
        related=id;
      }
      NetworkVO vo=new NetworkVO(id,network,offering.getId(),plan.getDataCenterId(),guru.getName(),owner.getDomainId(),owner.getId(),related,name,displayText,isShared,isDefault,predefined.isSecurityGroupEnabled(),(domainId != null),predefined.getNetworkDomain());
      vo.setTags(tags);
      networks.add(_networksDao.persist(vo,vo.getGuestType() != null));
      if (domainId != null) {
        _networksDao.addDomainToNetwork(id,domainId);
      }
    }
    if (networks.size() < 1) {
      throw new CloudRuntimeException("String_Node_Str" + offering.getId());
    }
    return networks;
  }
  finally {
    s_logger.debug("String_Node_Str" + locked);
    _accountDao.releaseFromLockTable(locked.getId());
  }
}