Program: 74933
Project: 74933
Buggy source:
/** 
 * Perform the action. 
 */
public void actionPerformed(ActionEvent e){
  super.actionPerformed(e);
  Query query=new Query();
  query.addLine("String_Node_Str","String_Node_Str","String_Node_Str");
  ComponentDialog dialog=new ComponentDialog(CaseGraphFrame.this,"String_Node_Str",query);
  if (dialog.buttonPressed().equals("String_Node_Str")) {
    final String pattern=query.getStringValue("String_Node_Str");
    String moml="String_Node_Str" + pattern + "String_Node_Str";
    MoMLChangeRequest change=new MoMLChangeRequest(this,_case,moml){
      protected void _execute() throws Exception {
        super._execute();
        Entity defaultRefinement=_case.getEntity("String_Node_Str");
        if (defaultRefinement != null) {
          defaultRefinement.moveToLast();
        }
        Entity entity=_case.getEntity(pattern);
        Iterator ports=_case.portList().iterator();
        while (ports.hasNext()) {
          Port port=(Port)ports.next();
          if (port == _case.control.getPort()) {
            continue;
          }
          try {
            if (entity instanceof Refinement) {
              ((Refinement)entity).setMirrorDisable(true);
            }
 else             if (entity instanceof ModalController) {
              ((ModalController)entity).setMirrorDisable(true);
            }
            Port newPort=entity.newPort(port.getName());
            if (newPort instanceof RefinementPort && port instanceof IOPort) {
              try {
                ((RefinementPort)newPort).setMirrorDisable(true);
                if (((IOPort)port).isInput()) {
                  ((RefinementPort)newPort).setInput(true);
                }
                if (((IOPort)port).isOutput()) {
                  ((RefinementPort)newPort).setOutput(true);
                }
                if (((IOPort)port).isMultiport()) {
                  ((RefinementPort)newPort).setMultiport(true);
                }
              }
  finally {
                ((RefinementPort)newPort).setMirrorDisable(false);
              }
            }
          }
  finally {
            if (entity instanceof Refinement) {
              ((Refinement)entity).setMirrorDisable(false);
            }
 else             if (entity instanceof ModalController) {
              ((ModalController)entity).setMirrorDisable(false);
            }
          }
        }
      }
    }
;
    _case.requestChange(change);
  }
}

Fixed version (ground truth):
/** 
 * Perform the action. 
 */
public void actionPerformed(ActionEvent e){
  super.actionPerformed(e);
  Query query=new Query();
  List refinements=_case.entityList(Refinement.class);
  if (refinements.size() < 2) {
    MessageHandler.error("String_Node_Str");
  }
 else {
    String[] caseNames=new String[refinements.size() - 1];
    Iterator cases=refinements.iterator();
    int i=0;
    while (cases.hasNext()) {
      String name=((Nameable)cases.next()).getName();
      if (!name.equals("String_Node_Str")) {
        caseNames[i]=name;
        i++;
      }
    }
    query.addChoice("String_Node_Str","String_Node_Str",caseNames,caseNames[0]);
    ComponentDialog dialog=new ComponentDialog(CaseGraphFrame.this,"String_Node_Str",query);
    if (dialog.buttonPressed().equals("String_Node_Str")) {
      final String name=query.getStringValue("String_Node_Str");
      String moml="String_Node_Str" + StringUtilities.escapeForXML(name) + "String_Node_Str";
      MoMLChangeRequest change=new MoMLChangeRequest(this,_case,moml){
        protected void _execute() throws Exception {
          super._execute();
          int count=_tabbedPane.getTabCount();
          for (int i=0; i < count; i++) {
            if (name.equals(_tabbedPane.getTitleAt(i))) {
              _tabbedPane.remove(i);
              break;
            }
          }
        }
      }
;
      _case.requestChange(change);
    }
  }
}