Program: 89617
Project: 89617
Buggy source:
@Override public Network design(NetworkOffering offering,DeploymentPlan plan,Network userSpecified,Account owner){
  DataCenter dc=_dcDao.findById(plan.getDataCenterId());
  if (!canHandle(offering,dc)) {
    return null;
  }
  NetworkVO network=new NetworkVO(offering.getTrafficType(),offering.getGuestType(),Mode.Dhcp,BroadcastDomainType.Vlan,offering.getId(),plan.getDataCenterId(),State.Allocated);
  if (userSpecified != null) {
    if ((userSpecified.getCidr() == null && userSpecified.getGateway() != null) || (userSpecified.getCidr() != null && userSpecified.getGateway() == null)) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
    if (userSpecified.getCidr() != null) {
      network.setCidr(userSpecified.getCidr());
      network.setGateway(userSpecified.getGateway());
    }
 else {
      String guestNetworkCidr=dc.getGuestNetworkCidr();
      if (guestNetworkCidr != null) {
        String[] cidrTuple=guestNetworkCidr.split("String_Node_Str");
        network.setGateway(NetUtils.getIpRangeStartIpFromCidr(cidrTuple[0],Long.parseLong(cidrTuple[1])));
        network.setCidr(guestNetworkCidr);
      }
    }
    if (userSpecified.getBroadcastUri() != null) {
      network.setBroadcastUri(userSpecified.getBroadcastUri());
      network.setState(State.Setup);
    }
    if (userSpecified.getNetworkDomain() != null) {
      network.setNetworkDomain(userSpecified.getNetworkDomain());
    }
  }
 else {
    String guestNetworkCidr=dc.getGuestNetworkCidr();
    String[] cidrTuple=guestNetworkCidr.split("String_Node_Str");
    network.setGateway(NetUtils.getIpRangeStartIpFromCidr(cidrTuple[0],Long.parseLong(cidrTuple[1])));
    network.setCidr(guestNetworkCidr);
    ;
  }
  return network;
}

Fixed version (ground truth):
@Override public Network design(NetworkOffering offering,DeploymentPlan plan,Network userSpecified,Account owner){
  DataCenter dc=_dcDao.findById(plan.getDataCenterId());
  if (!canHandle(offering,dc)) {
    return null;
  }
  NetworkVO network=new NetworkVO(offering.getTrafficType(),offering.getGuestType(),Mode.Dhcp,BroadcastDomainType.Vlan,offering.getId(),plan.getDataCenterId(),State.Allocated);
  if (userSpecified != null) {
    if ((userSpecified.getCidr() == null && userSpecified.getGateway() != null) || (userSpecified.getCidr() != null && userSpecified.getGateway() == null)) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
    if (userSpecified.getCidr() != null) {
      network.setCidr(userSpecified.getCidr());
      network.setGateway(userSpecified.getGateway());
    }
 else {
      String guestNetworkCidr=dc.getGuestNetworkCidr();
      if (guestNetworkCidr != null) {
        String[] cidrTuple=guestNetworkCidr.split("String_Node_Str");
        network.setGateway(NetUtils.getIpRangeStartIpFromCidr(cidrTuple[0],Long.parseLong(cidrTuple[1])));
        network.setCidr(guestNetworkCidr);
      }
    }
    if (userSpecified.getBroadcastUri() != null) {
      network.setBroadcastUri(userSpecified.getBroadcastUri());
      network.setState(State.Setup);
    }
  }
 else {
    String guestNetworkCidr=dc.getGuestNetworkCidr();
    String[] cidrTuple=guestNetworkCidr.split("String_Node_Str");
    network.setGateway(NetUtils.getIpRangeStartIpFromCidr(cidrTuple[0],Long.parseLong(cidrTuple[1])));
    network.setCidr(guestNetworkCidr);
    ;
  }
  return network;
}