Program: 133325
Project: 133325
Buggy source:
/** 
 * <p> Constructs the MasterDetailsComponent that allows the user to add and delete Ports entries. Supplies some limitations on the types of ports that are allowed in the MasterDetailsComponent that aligns with the IPS framework. </p>
 * @param ipsComponents The DataComponents to be put into the MasterDetailsComponent
 * @return the resultant MasterDetailsComponent
 */
private MasterDetailsComponent buildMasterDetailsComponent(ArrayList<DataComponent> ipsComponents){
  MasterDetailsComponent masterDetails=new MasterDetailsComponent();
  masterDetails.setName("String_Node_Str");
  masterDetails.setDescription("String_Node_Str");
  String portName;
  int masterId;
  String[] allowedPortNames={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  ArrayList<String> allowedPortList=new ArrayList<String>(Arrays.asList(allowedPortNames));
  ArrayList<DataComponent> portTemplates=new ArrayList<DataComponent>();
  Boolean portAdded;
  for (int i=0; i < ipsComponents.size(); i++) {
    DataComponent data=ipsComponents.get(i);
    portTemplates.add(data);
    allowedPortList.remove(data.getName());
  }
  if (allowedPortList.size() > 0 && portMap == null) {
    populatePortMap();
  }
  for (  String port : allowedPortList) {
    portTemplates.add(loadComponent(portMap.get(port).iterator()));
  }
  allowedPortList=new ArrayList<String>(Arrays.asList(allowedPortNames));
  masterDetails.setTemplates(allowedPortList,portTemplates);
  for (  DataComponent data : ipsComponents) {
    masterId=masterDetails.addMaster();
    portName=data.getName();
    masterDetails.setMasterInstanceValue(masterId,portName);
    masterDetails.getDetailsAtIndex(masterId - 1).copy(data);
  }
  return masterDetails;
}

Fixed version (ground truth):
/** 
 * <p> Constructs the MasterDetailsComponent that allows the user to add and delete Ports entries. Supplies some limitations on the types of ports that are allowed in the MasterDetailsComponent that aligns with the IPS framework. </p>
 * @param ipsComponents The DataComponents to be put into the MasterDetailsComponent
 * @return the resultant MasterDetailsComponent
 */
private MasterDetailsComponent buildMasterDetailsComponent(ArrayList<DataComponent> ipsComponents){
  MasterDetailsComponent masterDetails=new MasterDetailsComponent();
  masterDetails.setName("String_Node_Str");
  masterDetails.setDescription("String_Node_Str");
  String portName;
  int masterId;
  String[] allowedPortNames={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  ArrayList<String> allowedPortList=new ArrayList<String>(Arrays.asList(allowedPortNames));
  ArrayList<DataComponent> portTemplates=new ArrayList<DataComponent>();
  Boolean portAdded;
  for (int i=0; i < ipsComponents.size(); i++) {
    DataComponent data=ipsComponents.get(i);
    portTemplates.add(data);
    allowedPortList.remove(data.getName());
  }
  if (allowedPortList.size() > 0 && portMap == null) {
    populatePortMap();
  }
  for (  String port : allowedPortList) {
    portTemplates.add(loadComponent(portMap.get(port).iterator()));
  }
  allowedPortList=new ArrayList<String>(Arrays.asList(allowedPortNames));
  masterDetails.setTemplates(allowedPortList,portTemplates);
  for (  DataComponent data : ipsComponents) {
    masterId=masterDetails.addMaster();
    portName=data.getName();
    masterDetails.setMasterInstanceValue(masterId,portName);
    masterDetails.getDetailsAtIndex(masterId - 1).copy(data);
  }
  return masterDetails;
}