Program: 75888
Project: 75888
Buggy source:
/** 
 * Connect the given edge to the given head node. This class queues a new change request with the ptolemy model to make this modification.
 * @param edge The edge, which is assumed to be a link.
 * @param head The new head for the edge, which is assumed tobe a location representing a port, a port or a vertex.	 
 */
public void setHead(final Object edge,final Object newLinkHead){
  final Link link=(Link)edge;
  final NamedObj linkHead=(NamedObj)link.getHead();
  final NamedObj linkTail=(NamedObj)link.getTail();
  Relation linkRelation=(Relation)link.getRelation();
  final StringBuffer moml=new StringBuffer();
  final StringBuffer failmoml=new StringBuffer();
  moml.append("String_Node_Str");
  failmoml.append("String_Node_Str");
  final CompositeEntity container=(CompositeEntity)getChangeRequestParent(getToplevel());
  String relationName="String_Node_Str";
  try {
    _unlinkMoML(container,moml,linkHead,linkTail,linkRelation);
    relationName=_linkMoML(container,moml,failmoml,(NamedObj)newLinkHead,linkTail);
  }
 catch (  Exception ex) {
    _linkSet.remove(link);
    link.setHead(null);
    link.setTail(null);
    dispatchGraphEvent(new GraphEvent(PtolemyGraphModel.this,GraphEvent.STRUCTURE_CHANGED,getRoot()));
  }
  moml.append("String_Node_Str");
  failmoml.append("String_Node_Str");
  final String relationNameToAdd=relationName;
  ChangeRequest request=new MoMLChangeRequest(PtolemyGraphModel.this,container,moml.toString()){
    protected void _execute() throws Exception {
      super._execute();
      link.setHead(newLinkHead);
      if (relationNameToAdd != null) {
        ComponentRelation relation=(ComponentRelation)getToplevel().getRelation(relationNameToAdd);
        link.setRelation(relation);
      }
 else {
        link.setRelation(null);
      }
    }
  }
;
  request.addChangeListener(new LinkChangeListener(link,container,failmoml));
  container.requestChange(request);
}

Fixed version (ground truth):
/** 
 * Connect the given edge to the given head node. This class queues a new change request with the ptolemy model to make this modification.
 * @param edge The edge, which is assumed to be a link.
 * @param head The new head for the edge, which is assumed tobe a location representing a port, a port or a vertex.	 
 */
public void setHead(final Object edge,final Object newLinkHead){
  final Link link=(Link)edge;
  final NamedObj linkHead=(NamedObj)link.getHead();
  final NamedObj linkTail=(NamedObj)link.getTail();
  Relation linkRelation=(Relation)link.getRelation();
  final StringBuffer moml=new StringBuffer();
  final StringBuffer failmoml=new StringBuffer();
  moml.append("String_Node_Str");
  failmoml.append("String_Node_Str");
  final CompositeEntity container=(CompositeEntity)getChangeRequestParent(getToplevel());
  String relationName="String_Node_Str";
  try {
    _unlinkMoML(container,moml,linkHead,linkTail,linkRelation);
    relationName=_linkMoML(container,moml,failmoml,(NamedObj)newLinkHead,linkTail);
  }
 catch (  Exception ex) {
    _linkSet.remove(link);
    link.setHead(null);
    link.setTail(null);
    dispatchGraphEvent(new GraphEvent(PtolemyGraphModel.this,GraphEvent.STRUCTURE_CHANGED,getRoot()));
  }
  moml.append("String_Node_Str");
  failmoml.append("String_Node_Str");
  final String relationNameToAdd=relationName;
  ChangeRequest request=new MoMLChangeRequest(PtolemyGraphModel.this,container,moml.toString()){
    protected void _execute() throws Exception {
      super._execute();
      link.setHead(newLinkHead);
      if (relationNameToAdd != null) {
        ComponentRelation relation=(ComponentRelation)container.getRelation(relationNameToAdd);
        link.setRelation(relation);
      }
 else {
        link.setRelation(null);
      }
    }
  }
;
  request.addChangeListener(new LinkChangeListener(link,container,failmoml));
  container.requestChange(request);
}