Program: 74043
Project: 74043
Buggy source:
/** 
 * React to this item being selected. In this base class, if a source file is specified in the configuration of this item, e.g.: <pre> &lt;configure source="some_file.xml"&gt; &lt;/configure&gt; </pre> then the source is read and its contents are used as the moml text. The moml text can also be given directly: <pre> &lt;configure&gt; &lt;entity name="C" class="ptolemy.actor.lib.Const"&gt; &lt;/entity&gt; &lt;/configure&gt; </pre> Depending on whether the parse parameter is true or false, the moml text may be parsed first or not. If it is parsed, the returned NamedObj is used to generate a new moml string to be applied to the model in the current tableau (the nearest tableau that contains this GUI property). If it is not parsed, then the moml text is directly applied to the model.
 * @param parse Whether the configure text should be parsed before applyingto the current model.
 * @throws Exception If error occurs in performing the action.
 */
public void perform(boolean parse) throws Exception {
  if (_momlText != null) {
    NamedObj model=getModel();
    String moml;
    if (parse) {
      _parseSource();
      moml=getMoml(model,_parsedObject);
    }
 else {
      if (_momlSource != null) {
        URL url=_parser.fileNameToURL(_momlSource,null);
        InputStreamReader reader=null;
        try {
          reader=new InputStreamReader(url.openStream());
          int bufferSize=1024;
          char[] buffer=new char[bufferSize];
          int readSize=0;
          StringBuffer string=new StringBuffer();
          while (readSize >= 0) {
            readSize=reader.read(buffer);
            if (readSize >= 0) {
              string.append(buffer,0,readSize);
            }
          }
          _momlText=string.toString();
          _momlSource=null;
        }
  finally {
          if (reader != null) {
            try {
              reader.close();
            }
 catch (            IOException ex) {
              throw new InternalErrorException("String_Node_Str" + url + "String_Node_Str");
            }
          }
        }
      }
      moml=_momlText;
    }
    MoMLChangeRequest request=new MoMLChangeRequest(this,model,moml){
      protected void _postParse(      MoMLParser parser){
        Iterator topObjects=parser.topObjectsCreated().iterator();
        while (topObjects.hasNext()) {
          NamedObj topObject=(NamedObj)topObjects.next();
          if (topObject.attributeList(Location.class).isEmpty()) {
            try {
              Location location=new Location(topObject,topObject.uniqueName("String_Node_Str"));
              Point2D center=((BasicGraphFrame)getFrame()).getCenter();
              location.setLocation(new double[]{center.getX(),center.getY()});
            }
 catch (            KernelException e) {
              throw new InternalErrorException(e);
            }
          }
        }
        parser.clearTopObjectsList();
      }
      protected void _preParse(      MoMLParser parser){
        super._preParse(parser);
        parser.clearTopObjectsList();
      }
    }
;
    request.setUndoable(true);
    model.requestChange(request);
  }
}

Fixed version (ground truth):
/** 
 * React to this item being selected. In this base class, if a source file is specified in the configuration of this item, e.g.: <pre> &lt;configure source="some_file.xml"&gt; &lt;/configure&gt; </pre> then the source is read and its contents are used as the moml text. The moml text can also be given directly: <pre> &lt;configure&gt; &lt;entity name="C" class="ptolemy.actor.lib.Const"&gt; &lt;/entity&gt; &lt;/configure&gt; </pre> Depending on whether the parse parameter is true or false, the moml text may be parsed first or not. If it is parsed, the returned NamedObj is used to generate a new moml string to be applied to the model in the current tableau (the nearest tableau that contains this GUI property). If it is not parsed, then the moml text is directly applied to the model.
 * @param parse Whether the configure text should be parsed before applyingto the current model.
 * @exception Exception If error occurs in performing the action.
 */
public void perform(boolean parse) throws Exception {
  if (_momlText != null) {
    NamedObj model=getModel();
    String moml;
    if (parse) {
      _parseSource();
      moml=getMoml(model,_parsedObject);
    }
 else {
      if (_momlSource != null) {
        URL url=_parser.fileNameToURL(_momlSource,null);
        InputStreamReader reader=null;
        try {
          reader=new InputStreamReader(url.openStream());
          int bufferSize=1024;
          char[] buffer=new char[bufferSize];
          int readSize=0;
          StringBuffer string=new StringBuffer();
          while (readSize >= 0) {
            readSize=reader.read(buffer);
            if (readSize >= 0) {
              string.append(buffer,0,readSize);
            }
          }
          _momlText=string.toString();
          _momlSource=null;
        }
  finally {
          if (reader != null) {
            try {
              reader.close();
            }
 catch (            IOException ex) {
              throw new InternalErrorException("String_Node_Str" + url + "String_Node_Str");
            }
          }
        }
      }
      moml=_momlText;
    }
    MoMLChangeRequest request=new MoMLChangeRequest(this,model,moml){
      protected void _postParse(      MoMLParser parser){
        Iterator topObjects=parser.topObjectsCreated().iterator();
        while (topObjects.hasNext()) {
          NamedObj topObject=(NamedObj)topObjects.next();
          if (topObject.attributeList(Location.class).isEmpty()) {
            try {
              Location location=new Location(topObject,topObject.uniqueName("String_Node_Str"));
              Point2D center=((BasicGraphFrame)getFrame()).getCenter();
              location.setLocation(new double[]{center.getX(),center.getY()});
            }
 catch (            KernelException e) {
              throw new InternalErrorException(e);
            }
          }
        }
        parser.clearTopObjectsList();
      }
      protected void _preParse(      MoMLParser parser){
        super._preParse(parser);
        parser.clearTopObjectsList();
      }
    }
;
    request.setUndoable(true);
    model.requestChange(request);
  }
}