Program: 105617
Project: 105617
Buggy source:
private Network commitNetwork(final Long networkOfferingId,final String gateway,final String startIP,final String endIP,final String netmask,final String networkDomain,final String vlanId,final String name,final String displayText,final Account caller,final Long physicalNetworkId,final Long zoneId,final Long domainId,final boolean isDomainSpecific,final Boolean subdomainAccessFinal,final Long vpcId,final String startIPv6,final String endIPv6,final String ip6Gateway,final String ip6Cidr,final Boolean displayNetwork,final Long aclId,final String isolatedPvlan,final NetworkOfferingVO ntwkOff,final PhysicalNetwork pNtwk,final ACLType aclType,final Account ownerFinal,final String cidr,final boolean createVlan) throws InsufficientCapacityException, ResourceAllocationException {
  try {
    return Transaction.execute(new TransactionCallbackWithException<Network,Exception>(){
      @Override public Network doInTransaction(      TransactionStatus status) throws InsufficientCapacityException, ResourceAllocationException {
        Account owner=ownerFinal;
        Boolean subdomainAccess=subdomainAccessFinal;
        Long sharedDomainId=null;
        if (isDomainSpecific) {
          if (domainId != null) {
            sharedDomainId=domainId;
          }
 else {
            sharedDomainId=_domainMgr.getDomain(Domain.ROOT_DOMAIN).getId();
            subdomainAccess=true;
          }
        }
        if (aclType == ACLType.Domain) {
          owner=_accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM);
        }
        Network network=null;
        if (vpcId != null) {
          if (!_configMgr.isOfferingForVpc(ntwkOff)) {
            throw new InvalidParameterValueException("String_Node_Str");
          }
          if (aclId != null) {
            NetworkACL acl=_networkACLDao.findById(aclId);
            if (acl == null) {
              throw new InvalidParameterValueException("String_Node_Str");
            }
            if (aclId != NetworkACL.DEFAULT_DENY && aclId != NetworkACL.DEFAULT_ALLOW) {
              if (!vpcId.equals(acl.getVpcId())) {
                throw new InvalidParameterValueException("String_Node_Str" + aclId + "String_Node_Str");
              }
            }
          }
          network=_vpcMgr.createVpcGuestNetwork(networkOfferingId,name,displayText,gateway,cidr,vlanId,networkDomain,owner,sharedDomainId,pNtwk,zoneId,aclType,subdomainAccess,vpcId,aclId,caller,displayNetwork);
        }
 else {
          if (_configMgr.isOfferingForVpc(ntwkOff)) {
            throw new InvalidParameterValueException("String_Node_Str");
          }
          if (ntwkOff.getInternalLb()) {
            throw new InvalidParameterValueException("String_Node_Str");
          }
          network=_networkMgr.createGuestNetwork(networkOfferingId,name,displayText,gateway,cidr,vlanId,networkDomain,owner,sharedDomainId,pNtwk,zoneId,aclType,subdomainAccess,vpcId,ip6Gateway,ip6Cidr,displayNetwork,isolatedPvlan);
        }
        if (_accountMgr.isRootAdmin(caller.getId()) && createVlan) {
          _configMgr.createVlanAndPublicIpRange(pNtwk.getDataCenterId(),network.getId(),physicalNetworkId,false,null,startIP,endIP,gateway,netmask,vlanId,null,startIPv6,endIPv6,ip6Gateway,ip6Cidr);
        }
        return network;
      }
    }
);
  }
 catch (  Exception e) {
    ExceptionUtil.rethrowRuntime(e);
    ExceptionUtil.rethrow(e,InsufficientCapacityException.class);
    ExceptionUtil.rethrow(e,ResourceAllocationException.class);
    throw new IllegalStateException(e);
  }
}

Fixed version (ground truth):
private Network commitNetwork(final Long networkOfferingId,final String gateway,final String startIP,final String endIP,final String netmask,final String networkDomain,final String vlanId,final String name,final String displayText,final Account caller,final Long physicalNetworkId,final Long zoneId,final Long domainId,final boolean isDomainSpecific,final Boolean subdomainAccessFinal,final Long vpcId,final String startIPv6,final String endIPv6,final String ip6Gateway,final String ip6Cidr,final Boolean displayNetwork,final Long aclId,final String isolatedPvlan,final NetworkOfferingVO ntwkOff,final PhysicalNetwork pNtwk,final ACLType aclType,final Account ownerFinal,final String cidr,final boolean createVlan) throws InsufficientCapacityException, ResourceAllocationException {
  try {
    return Transaction.execute(new TransactionCallbackWithException<Network,Exception>(){
      @Override public Network doInTransaction(      TransactionStatus status) throws InsufficientCapacityException, ResourceAllocationException {
        Account owner=ownerFinal;
        Boolean subdomainAccess=subdomainAccessFinal;
        Long sharedDomainId=null;
        if (isDomainSpecific) {
          if (domainId != null) {
            sharedDomainId=domainId;
          }
 else {
            sharedDomainId=_domainMgr.getDomain(Domain.ROOT_DOMAIN).getId();
            subdomainAccess=true;
          }
        }
        if (aclType == ACLType.Domain) {
          owner=_accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM);
        }
        Network network=null;
        if (vpcId != null) {
          if (!_configMgr.isOfferingForVpc(ntwkOff)) {
            throw new InvalidParameterValueException("String_Node_Str");
          }
          if (aclId != null) {
            NetworkACL acl=_networkACLDao.findById(aclId);
            if (acl == null) {
              throw new InvalidParameterValueException("String_Node_Str");
            }
            if (aclId != NetworkACL.DEFAULT_DENY && aclId != NetworkACL.DEFAULT_ALLOW) {
              if (!vpcId.equals(acl.getVpcId())) {
                throw new InvalidParameterValueException("String_Node_Str" + aclId + "String_Node_Str");
              }
            }
          }
          network=_vpcMgr.createVpcGuestNetwork(networkOfferingId,name,displayText,gateway,cidr,vlanId,networkDomain,owner,sharedDomainId,pNtwk,zoneId,aclType,subdomainAccess,vpcId,aclId,caller,displayNetwork);
        }
 else {
          if (_configMgr.isOfferingForVpc(ntwkOff)) {
            throw new InvalidParameterValueException("String_Node_Str");
          }
          if (ntwkOff.getInternalLb()) {
            throw new InvalidParameterValueException("String_Node_Str");
          }
          network=_networkMgr.createGuestNetwork(networkOfferingId,name,displayText,gateway,cidr,vlanId,networkDomain,owner,sharedDomainId,pNtwk,zoneId,aclType,subdomainAccess,vpcId,ip6Gateway,ip6Cidr,displayNetwork,isolatedPvlan);
        }
        if (_accountMgr.isRootAdmin(caller.getId()) && createVlan && network != null) {
          _configMgr.createVlanAndPublicIpRange(pNtwk.getDataCenterId(),network.getId(),physicalNetworkId,false,null,startIP,endIP,gateway,netmask,vlanId,null,startIPv6,endIPv6,ip6Gateway,ip6Cidr);
        }
        return network;
      }
    }
);
  }
 catch (  Exception e) {
    ExceptionUtil.rethrowRuntime(e);
    ExceptionUtil.rethrow(e,InsufficientCapacityException.class);
    ExceptionUtil.rethrow(e,ResourceAllocationException.class);
    throw new IllegalStateException(e);
  }
}