Program: 75003
Project: 75003
Buggy source:
private void _placePortFigures(CompositeFigure figure,List portList,int direction){
  Iterator ports=portList.iterator();
  int number=0;
  int count=portList.size();
  while (ports.hasNext()) {
    Port port=(Port)ports.next();
    Figure portFigure=getController().getFigure(port);
    if (portFigure == null) {
      continue;
    }
    Rectangle2D portBounds=portFigure.getShape().getBounds2D();
    PortSite site=new PortSite(figure.getBackgroundFigure(),port,number,count);
    number++;
    double x=site.getX() - portBounds.getCenterX();
    double y=site.getY() - portBounds.getCenterY();
    portFigure.translate(x,y);
    Attribute showRateAttribute=port.getAttribute("String_Node_Str");
    if (port instanceof IOPort && showRateAttribute instanceof Variable) {
      boolean showRate=false;
      try {
        showRate=((Variable)showRateAttribute).getToken().equals(BooleanToken.TRUE);
      }
 catch (      Exception ex) {
      }
      if (showRate) {
        String rateString="String_Node_Str";
        Variable rateParameter=null;
        if (((IOPort)port).isInput()) {
          rateParameter=(Variable)port.getAttribute("String_Node_Str");
          if (rateParameter == null) {
            String altName="String_Node_Str";
            rateParameter=(Variable)port.getAttribute(altName);
          }
        }
 else         if (((IOPort)port).isOutput()) {
          rateParameter=(Variable)port.getAttribute("String_Node_Str");
          if (rateParameter == null) {
            String altName="String_Node_Str";
            rateParameter=(Variable)port.getAttribute(altName);
          }
        }
        if (rateParameter != null) {
          try {
            rateString=rateParameter.getToken().toString();
          }
 catch (          KernelException ex) {
          }
        }
        LabelFigure labelFigure=_createPortLabelFigure(rateString,_portLabelFont,x,y,direction);
        labelFigure.setFillPaint(Color.BLUE);
        figure.add(labelFigure);
      }
    }
    Attribute showAttribute=port.getAttribute("String_Node_Str");
    if (showAttribute != null) {
      boolean show=true;
      if (showAttribute instanceof Parameter) {
        try {
          Token token=((Parameter)showAttribute).getToken();
          if (token instanceof BooleanToken) {
            show=((BooleanToken)token).booleanValue();
          }
        }
 catch (        IllegalActionException e) {
        }
      }
      if (show) {
        LabelFigure labelFigure=_createPortLabelFigure(port.getName(),_portLabelFont,x,y,direction);
        figure.add(labelFigure);
      }
    }
  }
}

Fixed version (ground truth):
private void _placePortFigures(CompositeFigure figure,List portList,int direction){
  Iterator ports=portList.iterator();
  int number=0;
  int count=portList.size();
  Figure background=figure.getBackgroundFigure();
  if (background == null) {
    background=figure;
  }
  while (ports.hasNext()) {
    Port port=(Port)ports.next();
    Figure portFigure=getController().getFigure(port);
    if (portFigure == null) {
      continue;
    }
    Rectangle2D portBounds=portFigure.getShape().getBounds2D();
    PortSite site=new PortSite(background,port,number,count);
    number++;
    double x=site.getX() - portBounds.getCenterX();
    double y=site.getY() - portBounds.getCenterY();
    portFigure.translate(x,y);
    Attribute showRateAttribute=port.getAttribute("String_Node_Str");
    if (port instanceof IOPort && showRateAttribute instanceof Variable) {
      boolean showRate=false;
      try {
        showRate=((Variable)showRateAttribute).getToken().equals(BooleanToken.TRUE);
      }
 catch (      Exception ex) {
      }
      if (showRate) {
        String rateString="String_Node_Str";
        Variable rateParameter=null;
        if (((IOPort)port).isInput()) {
          rateParameter=(Variable)port.getAttribute("String_Node_Str");
          if (rateParameter == null) {
            String altName="String_Node_Str";
            rateParameter=(Variable)port.getAttribute(altName);
          }
        }
 else         if (((IOPort)port).isOutput()) {
          rateParameter=(Variable)port.getAttribute("String_Node_Str");
          if (rateParameter == null) {
            String altName="String_Node_Str";
            rateParameter=(Variable)port.getAttribute(altName);
          }
        }
        if (rateParameter != null) {
          try {
            rateString=rateParameter.getToken().toString();
          }
 catch (          KernelException ex) {
          }
        }
        LabelFigure labelFigure=_createPortLabelFigure(rateString,_portLabelFont,x,y,direction);
        labelFigure.setFillPaint(Color.BLUE);
        figure.add(labelFigure);
      }
    }
    Attribute showAttribute=port.getAttribute("String_Node_Str");
    if (showAttribute != null) {
      boolean show=true;
      if (showAttribute instanceof Parameter) {
        try {
          Token token=((Parameter)showAttribute).getToken();
          if (token instanceof BooleanToken) {
            show=((BooleanToken)token).booleanValue();
          }
        }
 catch (        IllegalActionException e) {
        }
      }
      if (show) {
        LabelFigure labelFigure=_createPortLabelFigure(port.getName(),_portLabelFont,x,y,direction);
        figure.add(labelFigure);
      }
    }
  }
}