Program: 74548
Project: 74548
Buggy source:
public void updateAppearance(GTIngredientsAttribute attribute){
  try {
    _workspace.getWriteAccess();
    Set<String> preservedPortNames=new HashSet<String>();
    boolean isIconSet=false;
    int i=1;
    GTIngredientList list=attribute.getIngredientList();
    for (    GTIngredient ingredient : list) {
      if (ingredient instanceof PortCriterion) {
        PortCriterion criterion=(PortCriterion)ingredient;
        String portID=criterion.getPortID(list);
        preservedPortNames.add(portID);
        TypedIOPort port=(TypedIOPort)getPort(portID);
        if (port != null) {
          port.setInput(criterion.isInput());
          port.setOutput(criterion.isOutput());
          port.setMultiport(criterion.isMultiport());
          port.setPersistent(false);
        }
 else {
          port=new TypedIOPort(this,portID,criterion.isInput(),criterion.isOutput());
          port.setMultiport(criterion.isMultiport());
          port.setPersistent(false);
        }
        port.setPersistent(false);
      }
 else       if (ingredient instanceof SubclassCriterion && !isIconSet) {
        SubclassCriterion criterion=(SubclassCriterion)ingredient;
        final String superclass=criterion.getSuperclass();
        requestChange(new ChangeRequest(this,"String_Node_Str"){
          protected void _execute(){
            _loadActorIcon(superclass);
          }
        }
);
        isIconSet=true;
      }
      i++;
    }
    if (!isIconSet) {
      requestChange(new RestoreAppearanceChangeRequest());
    }
    List<?> portList=portList();
    for (i=0; i < portList.size(); ) {
      Port port=(Port)portList.get(i);
      if (!preservedPortNames.contains(port.getName())) {
        port.setContainer(null);
      }
 else {
        i++;
      }
    }
    for (    Object portObject : portList()) {
      Port port=(Port)portObject;
      if (!preservedPortNames.contains(port.getName())) {
        port.setContainer(null);
      }
    }
  }
 catch (  KernelException e) {
    throw new KernelRuntimeException(e,"String_Node_Str" + "String_Node_Str" + getName() + "String_Node_Str");
  }
 finally {
    _workspace.doneWriting();
  }
}

Fixed version (ground truth):
public void updateAppearance(GTIngredientsAttribute attribute){
  try {
    _workspace.getWriteAccess();
    Set<String> preservedPortNames=new HashSet<String>();
    boolean isIconSet=false;
    int i=1;
    GTIngredientList list=attribute.getIngredientList();
    for (    GTIngredient ingredient : list) {
      if (ingredient instanceof PortCriterion) {
        PortCriterion criterion=(PortCriterion)ingredient;
        String portID=criterion.getPortID(list);
        preservedPortNames.add(portID);
        TypedIOPort port=(TypedIOPort)getPort(portID);
        boolean isInput=criterion.isInput();
        boolean isOutput=criterion.isOutput();
        boolean isMultiport=!criterion.isMultiportEnabled() || criterion.isMultiport();
        if (port != null) {
          port.setInput(isInput);
          port.setOutput(isOutput);
          port.setMultiport(isMultiport);
          port.setPersistent(false);
        }
 else {
          port=new TypedIOPort(this,portID,isInput,isOutput);
          port.setMultiport(isMultiport);
          port.setPersistent(false);
        }
        port.setPersistent(false);
      }
 else       if (ingredient instanceof SubclassCriterion && !isIconSet) {
        SubclassCriterion criterion=(SubclassCriterion)ingredient;
        final String superclass=criterion.getSuperclass();
        requestChange(new ChangeRequest(this,"String_Node_Str"){
          protected void _execute(){
            _loadActorIcon(superclass);
          }
        }
);
        isIconSet=true;
      }
      i++;
    }
    if (!isIconSet) {
      requestChange(new RestoreAppearanceChangeRequest());
    }
    List<?> portList=portList();
    for (i=0; i < portList.size(); ) {
      Port port=(Port)portList.get(i);
      if (!preservedPortNames.contains(port.getName())) {
        port.setContainer(null);
      }
 else {
        i++;
      }
    }
    for (    Object portObject : portList()) {
      Port port=(Port)portObject;
      if (!preservedPortNames.contains(port.getName())) {
        port.setContainer(null);
      }
    }
  }
 catch (  KernelException e) {
    throw new KernelRuntimeException(e,"String_Node_Str" + "String_Node_Str" + getName() + "String_Node_Str");
  }
 finally {
    _workspace.doneWriting();
  }
}