Program: 89468
Project: 89468
Buggy source:
@Override public void createDefaultNetworks(long zoneId,boolean isSecurityGroupEnabled) throws ConcurrentOperationException {
  DataCenterVO zone=_zoneDao.findById(zoneId);
  if (zone != null) {
    List<NetworkOfferingVO> ntwkOff=_networkOfferingDao.listSystemNetworkOfferings();
    for (    NetworkOfferingVO offering : ntwkOff) {
      DataCenterDeployment plan=new DataCenterDeployment(zone.getId(),null,null,null,null);
      NetworkVO userNetwork=new NetworkVO();
      Account systemAccount=_accountDao.findById(Account.ACCOUNT_ID_SYSTEM);
      BroadcastDomainType broadcastDomainType=null;
      boolean isNetworkDefault=false;
      if (offering.getTrafficType() == TrafficType.Management) {
        broadcastDomainType=BroadcastDomainType.Native;
      }
 else       if (offering.getTrafficType() == TrafficType.Control) {
        broadcastDomainType=BroadcastDomainType.LinkLocal;
      }
 else       if (offering.getTrafficType() == TrafficType.Public) {
        if ((zone.getNetworkType() == NetworkType.Advanced && !zone.isSecurityGroupEnabled()) || zone.getNetworkType() == NetworkType.Basic) {
          broadcastDomainType=BroadcastDomainType.Vlan;
        }
 else {
          continue;
        }
      }
 else       if (offering.getTrafficType() == TrafficType.Guest) {
        if (zone.getNetworkType() == NetworkType.Basic) {
          isNetworkDefault=true;
          broadcastDomainType=BroadcastDomainType.Native;
          userNetwork.setSecurityGroupEnabled(isSecurityGroupEnabled);
        }
 else         if (offering.getGuestType() == GuestIpType.Direct && isSecurityGroupEnabled) {
          isNetworkDefault=true;
          userNetwork.setSecurityGroupEnabled(isSecurityGroupEnabled);
        }
 else {
          continue;
        }
      }
      userNetwork.setBroadcastDomainType(broadcastDomainType);
      _networkMgr.setupNetwork(systemAccount,offering,userNetwork,plan,null,null,true,isNetworkDefault,false,null,null);
    }
  }
}

Fixed version (ground truth):
@Override public void createDefaultNetworks(long zoneId,boolean isSecurityGroupEnabled) throws ConcurrentOperationException {
  DataCenterVO zone=_zoneDao.findById(zoneId);
  String networkDomain=null;
  if (zone != null) {
    List<NetworkOfferingVO> ntwkOff=_networkOfferingDao.listSystemNetworkOfferings();
    for (    NetworkOfferingVO offering : ntwkOff) {
      DataCenterDeployment plan=new DataCenterDeployment(zone.getId(),null,null,null,null);
      NetworkVO userNetwork=new NetworkVO();
      Account systemAccount=_accountDao.findById(Account.ACCOUNT_ID_SYSTEM);
      BroadcastDomainType broadcastDomainType=null;
      boolean isNetworkDefault=false;
      if (offering.getTrafficType() == TrafficType.Management) {
        broadcastDomainType=BroadcastDomainType.Native;
      }
 else       if (offering.getTrafficType() == TrafficType.Control) {
        broadcastDomainType=BroadcastDomainType.LinkLocal;
      }
 else       if (offering.getTrafficType() == TrafficType.Public) {
        if ((zone.getNetworkType() == NetworkType.Advanced && !zone.isSecurityGroupEnabled()) || zone.getNetworkType() == NetworkType.Basic) {
          broadcastDomainType=BroadcastDomainType.Vlan;
        }
 else {
          continue;
        }
      }
 else       if (offering.getTrafficType() == TrafficType.Guest) {
        if (zone.getNetworkType() == NetworkType.Basic) {
          isNetworkDefault=true;
          broadcastDomainType=BroadcastDomainType.Native;
          userNetwork.setSecurityGroupEnabled(isSecurityGroupEnabled);
        }
 else         if (offering.getGuestType() == GuestIpType.Direct && isSecurityGroupEnabled) {
          isNetworkDefault=true;
          userNetwork.setSecurityGroupEnabled(isSecurityGroupEnabled);
        }
 else {
          continue;
        }
        networkDomain="String_Node_Str" + Long.toHexString(Account.ACCOUNT_ID_SYSTEM) + _networkMgr.getGlobalGuestDomainSuffix();
      }
      userNetwork.setBroadcastDomainType(broadcastDomainType);
      userNetwork.setNetworkDomain(networkDomain);
      _networkMgr.setupNetwork(systemAccount,offering,userNetwork,plan,null,null,true,isNetworkDefault,false,null,null);
    }
  }
}