Program: 105653
Project: 105653
Buggy source:
@Override public LibvirtVMDef.InterfaceDef plug(NicTO nic,String guestOsType,String nicAdapter) throws InternalErrorException, LibvirtException {
  if (s_logger.isDebugEnabled()) {
    s_logger.debug("String_Node_Str" + nic);
    if (nicAdapter != null && !nicAdapter.isEmpty()) {
      s_logger.debug("String_Node_Str" + nicAdapter);
    }
  }
  LibvirtVMDef.InterfaceDef intf=new LibvirtVMDef.InterfaceDef();
  String vNetId=null;
  String protocol=null;
  if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan || nic.getBroadcastType() == Networks.BroadcastDomainType.Vxlan) {
    vNetId=Networks.BroadcastDomainType.getValue(nic.getBroadcastUri());
    protocol=Networks.BroadcastDomainType.getSchemeValue(nic.getBroadcastUri()).scheme();
  }
 else   if (nic.getBroadcastType() == Networks.BroadcastDomainType.Lswitch) {
    throw new InternalErrorException("String_Node_Str");
  }
  String trafficLabel=nic.getName();
  if (nic.getType() == Networks.TrafficType.Guest) {
    Integer networkRateKBps=(nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
    if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan && !vNetId.equalsIgnoreCase("String_Node_Str") || nic.getBroadcastType() == Networks.BroadcastDomainType.Vxlan) {
      if (trafficLabel != null && !trafficLabel.isEmpty()) {
        s_logger.debug("String_Node_Str" + trafficLabel);
        String brName=createVnetBr(vNetId,trafficLabel,protocol);
        intf.defBridgeNet(brName,null,nic.getMac(),getGuestNicModel(guestOsType,nicAdapter),networkRateKBps);
      }
 else {
        String brName=createVnetBr(vNetId,"String_Node_Str",protocol);
        intf.defBridgeNet(brName,null,nic.getMac(),getGuestNicModel(guestOsType,nicAdapter),networkRateKBps);
      }
    }
 else {
      intf.defBridgeNet(_bridges.get("String_Node_Str"),null,nic.getMac(),getGuestNicModel(guestOsType,nicAdapter),networkRateKBps);
    }
  }
 else   if (nic.getType() == Networks.TrafficType.Control) {
    createControlNetwork();
    intf.defBridgeNet(_bridges.get("String_Node_Str"),null,nic.getMac(),getGuestNicModel(guestOsType,nicAdapter));
  }
 else   if (nic.getType() == Networks.TrafficType.Public) {
    Integer networkRateKBps=(nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
    if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan && !vNetId.equalsIgnoreCase("String_Node_Str") || nic.getBroadcastType() == Networks.BroadcastDomainType.Vxlan) {
      if (trafficLabel != null && !trafficLabel.isEmpty()) {
        s_logger.debug("String_Node_Str" + trafficLabel);
        String brName=createVnetBr(vNetId,trafficLabel,protocol);
        intf.defBridgeNet(brName,null,nic.getMac(),getGuestNicModel(guestOsType,nicAdapter),networkRateKBps);
      }
 else {
        String brName=createVnetBr(vNetId,"String_Node_Str",protocol);
        intf.defBridgeNet(brName,null,nic.getMac(),getGuestNicModel(guestOsType,nicAdapter),networkRateKBps);
      }
    }
 else {
      intf.defBridgeNet(_bridges.get("String_Node_Str"),null,nic.getMac(),getGuestNicModel(guestOsType,nicAdapter),networkRateKBps);
    }
  }
 else   if (nic.getType() == Networks.TrafficType.Management) {
    intf.defBridgeNet(_bridges.get("String_Node_Str"),null,nic.getMac(),getGuestNicModel(guestOsType,nicAdapter));
  }
 else   if (nic.getType() == Networks.TrafficType.Storage) {
    String storageBrName=nic.getName() == null ? _bridges.get("String_Node_Str") : nic.getName();
    intf.defBridgeNet(storageBrName,null,nic.getMac(),getGuestNicModel(guestOsType,nicAdapter));
  }
  if (nic.getPxeDisable() == true) {
    intf.setPxeDisable(true);
  }
  return intf;
}

Fixed version (ground truth):
@Override public LibvirtVMDef.InterfaceDef plug(NicTO nic,String guestOsType,String nicAdapter) throws InternalErrorException, LibvirtException {
  if (s_logger.isDebugEnabled()) {
    s_logger.debug("String_Node_Str" + nic);
    if (nicAdapter != null && !nicAdapter.isEmpty()) {
      s_logger.debug("String_Node_Str" + nicAdapter);
    }
  }
  LibvirtVMDef.InterfaceDef intf=new LibvirtVMDef.InterfaceDef();
  String vNetId=null;
  String protocol=null;
  if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan || nic.getBroadcastType() == Networks.BroadcastDomainType.Vxlan) {
    vNetId=Networks.BroadcastDomainType.getValue(nic.getBroadcastUri());
    protocol=Networks.BroadcastDomainType.getSchemeValue(nic.getBroadcastUri()).scheme();
  }
 else   if (nic.getBroadcastType() == Networks.BroadcastDomainType.Lswitch) {
    throw new InternalErrorException("String_Node_Str");
  }
  String trafficLabel=nic.getName();
  if (nic.getType() == Networks.TrafficType.Guest) {
    Integer networkRateKBps=(nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
    if ((nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan) && (vNetId != null) && (protocol != null)&& (!vNetId.equalsIgnoreCase("String_Node_Str")) || (nic.getBroadcastType() == Networks.BroadcastDomainType.Vxlan)) {
      if (trafficLabel != null && !trafficLabel.isEmpty()) {
        s_logger.debug("String_Node_Str" + trafficLabel);
        String brName=createVnetBr(vNetId,trafficLabel,protocol);
        intf.defBridgeNet(brName,null,nic.getMac(),getGuestNicModel(guestOsType,nicAdapter),networkRateKBps);
      }
 else {
        String brName=createVnetBr(vNetId,"String_Node_Str",protocol);
        intf.defBridgeNet(brName,null,nic.getMac(),getGuestNicModel(guestOsType,nicAdapter),networkRateKBps);
      }
    }
 else {
      intf.defBridgeNet(_bridges.get("String_Node_Str"),null,nic.getMac(),getGuestNicModel(guestOsType,nicAdapter),networkRateKBps);
    }
  }
 else   if (nic.getType() == Networks.TrafficType.Control) {
    createControlNetwork();
    intf.defBridgeNet(_bridges.get("String_Node_Str"),null,nic.getMac(),getGuestNicModel(guestOsType,nicAdapter));
  }
 else   if (nic.getType() == Networks.TrafficType.Public) {
    Integer networkRateKBps=(nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
    if ((nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan) && (vNetId != null) && (protocol != null)&& (!vNetId.equalsIgnoreCase("String_Node_Str")) || (nic.getBroadcastType() == Networks.BroadcastDomainType.Vxlan)) {
      if (trafficLabel != null && !trafficLabel.isEmpty()) {
        s_logger.debug("String_Node_Str" + trafficLabel);
        String brName=createVnetBr(vNetId,trafficLabel,protocol);
        intf.defBridgeNet(brName,null,nic.getMac(),getGuestNicModel(guestOsType,nicAdapter),networkRateKBps);
      }
 else {
        String brName=createVnetBr(vNetId,"String_Node_Str",protocol);
        intf.defBridgeNet(brName,null,nic.getMac(),getGuestNicModel(guestOsType,nicAdapter),networkRateKBps);
      }
    }
 else {
      intf.defBridgeNet(_bridges.get("String_Node_Str"),null,nic.getMac(),getGuestNicModel(guestOsType,nicAdapter),networkRateKBps);
    }
  }
 else   if (nic.getType() == Networks.TrafficType.Management) {
    intf.defBridgeNet(_bridges.get("String_Node_Str"),null,nic.getMac(),getGuestNicModel(guestOsType,nicAdapter));
  }
 else   if (nic.getType() == Networks.TrafficType.Storage) {
    String storageBrName=nic.getName() == null ? _bridges.get("String_Node_Str") : nic.getName();
    intf.defBridgeNet(storageBrName,null,nic.getMac(),getGuestNicModel(guestOsType,nicAdapter));
  }
  if (nic.getPxeDisable() == true) {
    intf.setPxeDisable(true);
  }
  return intf;
}