Program: 105616
Project: 105616
Buggy source:
@Override public Network doInTransaction(TransactionStatus status) throws ResourceAllocationException, InsufficientCapacityException {
  DataCenterVO dc=_dcDao.lockRow(pNtwk.getDataCenterId(),true);
  Network privateNetwork=_networksDao.getPrivateNetwork(uriString,cidr,networkOwnerId,pNtwk.getDataCenterId(),networkOfferingId);
  if (privateNetwork == null) {
    privateNetwork=_networkMgr.createGuestNetwork(ntwkOffFinal.getId(),networkName,displayText,gateway,cidr,uriString,null,owner,null,pNtwk,pNtwk.getDataCenterId(),ACLType.Account,null,vpcId,null,null,true,null);
    if (privateNetwork != null) {
      s_logger.debug("String_Node_Str" + privateNetwork);
    }
 else {
      throw new CloudRuntimeException("String_Node_Str");
    }
  }
 else {
    s_logger.debug("String_Node_Str" + privateNetwork);
    if (vpcId != null && vpcId.equals(privateNetwork.getVpcId())) {
      throw new InvalidParameterValueException("String_Node_Str" + uriString + "String_Node_Str"+ cidr+ "String_Node_Str"+ "String_Node_Str"+ vpcId+ "String_Node_Str"+ _entityMgr.findById(DataCenter.class,pNtwk.getDataCenterId()).getName());
    }
  }
  PrivateIpVO privateIp=_privateIpDao.findByIpAndSourceNetworkIdAndVpcId(privateNetwork.getId(),startIp,vpcId);
  if (privateIp != null) {
    throw new InvalidParameterValueException("String_Node_Str" + startIp + "String_Node_Str"+ "String_Node_Str"+ _entityMgr.findById(DataCenter.class,pNtwk.getDataCenterId()).getName());
  }
  Long mac=dc.getMacAddress();
  Long nextMac=mac + 1;
  dc.setMacAddress(nextMac);
  privateIp=new PrivateIpVO(startIp,privateNetwork.getId(),nextMac,vpcId,sourceNat);
  _privateIpDao.persist(privateIp);
  _dcDao.update(dc.getId(),dc);
  s_logger.debug("String_Node_Str" + privateNetwork + "String_Node_Str");
  return privateNetwork;
}

Fixed version (ground truth):
@Override public Network doInTransaction(TransactionStatus status) throws ResourceAllocationException, InsufficientCapacityException {
  DataCenterVO dc=_dcDao.lockRow(pNtwk.getDataCenterId(),true);
  Network privateNetwork=_networksDao.getPrivateNetwork(uriString,cidr,networkOwnerId,pNtwk.getDataCenterId(),networkOfferingId);
  if (privateNetwork == null) {
    privateNetwork=_networkMgr.createGuestNetwork(ntwkOffFinal.getId(),networkName,displayText,gateway,cidr,uriString,null,owner,null,pNtwk,pNtwk.getDataCenterId(),ACLType.Account,null,vpcId,null,null,true,null);
    if (privateNetwork != null) {
      s_logger.debug("String_Node_Str" + privateNetwork);
    }
 else {
      throw new CloudRuntimeException("String_Node_Str");
    }
  }
 else {
    s_logger.debug("String_Node_Str" + privateNetwork);
    if (vpcId != null && vpcId.equals(privateNetwork.getVpcId())) {
      throw new InvalidParameterValueException("String_Node_Str" + uriString + "String_Node_Str"+ cidr+ "String_Node_Str"+ "String_Node_Str"+ vpcId+ "String_Node_Str"+ _entityMgr.findById(DataCenter.class,pNtwk.getDataCenterId()).getName());
    }
  }
  if (vpcId != null) {
    PrivateIpVO privateIp=_privateIpDao.findByIpAndSourceNetworkIdAndVpcId(privateNetwork.getId(),startIp,vpcId);
    if (privateIp != null) {
      throw new InvalidParameterValueException("String_Node_Str" + startIp + "String_Node_Str"+ "String_Node_Str"+ _entityMgr.findById(DataCenter.class,pNtwk.getDataCenterId()).getName());
    }
    Long mac=dc.getMacAddress();
    Long nextMac=mac + 1;
    dc.setMacAddress(nextMac);
    privateIp=new PrivateIpVO(startIp,privateNetwork.getId(),nextMac,vpcId,sourceNat);
    _privateIpDao.persist(privateIp);
    _dcDao.update(dc.getId(),dc);
  }
  s_logger.debug("String_Node_Str" + privateNetwork + "String_Node_Str");
  return privateNetwork;
}