Program: 106279
Project: 106279
Buggy source:
@Override public InterfaceDef plug(NicTO nic,String guestOsType) throws InternalErrorException, LibvirtException {
  s_logger.debug("String_Node_Str" + nic);
  LibvirtVMDef.InterfaceDef intf=new LibvirtVMDef.InterfaceDef();
  intf.setVirtualPortType("String_Node_Str");
  String vlanId=null;
  String logicalSwitchUuid=null;
  if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan) {
    URI broadcastUri=nic.getBroadcastUri();
    vlanId=broadcastUri.getHost();
  }
 else   if (nic.getBroadcastType() == Networks.BroadcastDomainType.Lswitch) {
    logicalSwitchUuid=nic.getBroadcastUri().getSchemeSpecificPart();
  }
  String trafficLabel=nic.getName();
  if (nic.getType() == Networks.TrafficType.Guest) {
    if ((nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan || nic.getBroadcastType() == Networks.BroadcastDomainType.Pvlan) && !vlanId.equalsIgnoreCase("String_Node_Str")) {
      if (trafficLabel != null && !trafficLabel.isEmpty()) {
        s_logger.debug("String_Node_Str" + trafficLabel);
        intf.defBridgeNet(_pifs.get(trafficLabel),null,nic.getMac(),getGuestNicModel(guestOsType));
        intf.setVlanTag(Integer.parseInt(vlanId));
      }
 else {
        intf.defBridgeNet(_pifs.get("String_Node_Str"),null,nic.getMac(),getGuestNicModel(guestOsType));
        intf.setVlanTag(Integer.parseInt(vlanId));
      }
    }
 else     if (nic.getBroadcastType() == Networks.BroadcastDomainType.Lswitch) {
      s_logger.debug("String_Node_Str" + nic + "String_Node_Str"+ logicalSwitchUuid);
      intf.setVirtualPortInterfaceId(nic.getUuid());
      String brName=(trafficLabel != null && !trafficLabel.isEmpty()) ? _pifs.get(trafficLabel) : _pifs.get("String_Node_Str");
      intf.defBridgeNet(brName,null,nic.getMac(),getGuestNicModel(guestOsType));
    }
 else {
      intf.defBridgeNet(_bridges.get("String_Node_Str"),null,nic.getMac(),getGuestNicModel(guestOsType));
    }
  }
 else   if (nic.getType() == Networks.TrafficType.Control) {
    createControlNetwork(_bridges.get("String_Node_Str"));
    intf.defBridgeNet(_bridges.get("String_Node_Str"),null,nic.getMac(),getGuestNicModel(guestOsType));
  }
 else   if (nic.getType() == Networks.TrafficType.Public) {
    if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan && !vlanId.equalsIgnoreCase("String_Node_Str")) {
      if (trafficLabel != null && !trafficLabel.isEmpty()) {
        s_logger.debug("String_Node_Str" + trafficLabel);
        intf.defBridgeNet(_pifs.get(trafficLabel),null,nic.getMac(),getGuestNicModel(guestOsType));
        intf.setVlanTag(Integer.parseInt(vlanId));
      }
 else {
        intf.defBridgeNet(_pifs.get("String_Node_Str"),null,nic.getMac(),getGuestNicModel(guestOsType));
        intf.setVlanTag(Integer.parseInt(vlanId));
      }
    }
 else {
      intf.defBridgeNet(_bridges.get("String_Node_Str"),null,nic.getMac(),getGuestNicModel(guestOsType));
    }
  }
 else   if (nic.getType() == Networks.TrafficType.Management) {
    intf.defBridgeNet(_bridges.get("String_Node_Str"),null,nic.getMac(),getGuestNicModel(guestOsType));
  }
 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));
  }
  return intf;
}

Fixed version (ground truth):
@Override public InterfaceDef plug(NicTO nic,String guestOsType) throws InternalErrorException, LibvirtException {
  s_logger.debug("String_Node_Str" + nic);
  LibvirtVMDef.InterfaceDef intf=new LibvirtVMDef.InterfaceDef();
  intf.setVirtualPortType("String_Node_Str");
  String vlanId=null;
  String logicalSwitchUuid=null;
  if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan) {
    URI broadcastUri=nic.getBroadcastUri();
    vlanId=broadcastUri.getHost();
  }
 else   if (nic.getBroadcastType() == Networks.BroadcastDomainType.Lswitch) {
    logicalSwitchUuid=nic.getBroadcastUri().getSchemeSpecificPart();
  }
 else   if (nic.getBroadcastType() == Networks.BroadcastDomainType.Pvlan) {
    vlanId=NetUtils.getPrimaryPvlanFromUri(nic.getBroadcastUri());
  }
  String trafficLabel=nic.getName();
  if (nic.getType() == Networks.TrafficType.Guest) {
    if ((nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan || nic.getBroadcastType() == Networks.BroadcastDomainType.Pvlan) && !vlanId.equalsIgnoreCase("String_Node_Str")) {
      if (trafficLabel != null && !trafficLabel.isEmpty()) {
        s_logger.debug("String_Node_Str" + trafficLabel);
        intf.defBridgeNet(_pifs.get(trafficLabel),null,nic.getMac(),getGuestNicModel(guestOsType));
        intf.setVlanTag(Integer.parseInt(vlanId));
      }
 else {
        intf.defBridgeNet(_pifs.get("String_Node_Str"),null,nic.getMac(),getGuestNicModel(guestOsType));
        intf.setVlanTag(Integer.parseInt(vlanId));
      }
    }
 else     if (nic.getBroadcastType() == Networks.BroadcastDomainType.Lswitch) {
      s_logger.debug("String_Node_Str" + nic + "String_Node_Str"+ logicalSwitchUuid);
      intf.setVirtualPortInterfaceId(nic.getUuid());
      String brName=(trafficLabel != null && !trafficLabel.isEmpty()) ? _pifs.get(trafficLabel) : _pifs.get("String_Node_Str");
      intf.defBridgeNet(brName,null,nic.getMac(),getGuestNicModel(guestOsType));
    }
 else {
      intf.defBridgeNet(_bridges.get("String_Node_Str"),null,nic.getMac(),getGuestNicModel(guestOsType));
    }
  }
 else   if (nic.getType() == Networks.TrafficType.Control) {
    createControlNetwork(_bridges.get("String_Node_Str"));
    intf.defBridgeNet(_bridges.get("String_Node_Str"),null,nic.getMac(),getGuestNicModel(guestOsType));
  }
 else   if (nic.getType() == Networks.TrafficType.Public) {
    if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan && !vlanId.equalsIgnoreCase("String_Node_Str")) {
      if (trafficLabel != null && !trafficLabel.isEmpty()) {
        s_logger.debug("String_Node_Str" + trafficLabel);
        intf.defBridgeNet(_pifs.get(trafficLabel),null,nic.getMac(),getGuestNicModel(guestOsType));
        intf.setVlanTag(Integer.parseInt(vlanId));
      }
 else {
        intf.defBridgeNet(_pifs.get("String_Node_Str"),null,nic.getMac(),getGuestNicModel(guestOsType));
        intf.setVlanTag(Integer.parseInt(vlanId));
      }
    }
 else {
      intf.defBridgeNet(_bridges.get("String_Node_Str"),null,nic.getMac(),getGuestNicModel(guestOsType));
    }
  }
 else   if (nic.getType() == Networks.TrafficType.Management) {
    intf.defBridgeNet(_bridges.get("String_Node_Str"),null,nic.getMac(),getGuestNicModel(guestOsType));
  }
 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));
  }
  return intf;
}