Program: 76015
Project: 76015
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;
  NamedObj linkHead=(NamedObj)link.getHead();
  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");
  String relationName="String_Node_Str";
  try {
    _unlinkMoML(moml,linkHead,linkTail,linkRelation);
    relationName=_linkMoML(moml,failmoml,(NamedObj)newLinkHead,linkTail);
  }
 catch (  Exception ex) {
    throw new GraphException(ex);
  }
  moml.append("String_Node_Str");
  failmoml.append("String_Node_Str");
  final String relationNameToAdd=relationName;
  ChangeRequest request=new MoMLChangeRequest(PtolemyGraphModel.this,getToplevel(),moml.toString()){
    protected void _execute() throws Exception {
      super._execute();
      link.setHead(newLinkHead);
      if (relationNameToAdd != null) {
        link.setRelation(getToplevel().getRelation(relationNameToAdd));
      }
 else {
        link.setRelation(null);
      }
    }
  }
;
  request.addChangeListener(new ChangeListener(){
    public void changeFailed(    ChangeRequest change,    Exception exception){
      _linkSet.remove(link);
      link.setHead(null);
      link.setTail(null);
      link.setRelation(null);
      ChangeRequest request=new MoMLChangeRequest(PtolemyGraphModel.this,getToplevel(),failmoml.toString());
      getToplevel().requestChange(request);
    }
    public void changeExecuted(    ChangeRequest change){
      if (GraphUtilities.isPartiallyContainedEdge(edge,getRoot(),PtolemyGraphModel.this)) {
        _linkSet.add(edge);
      }
 else {
        _linkSet.remove(edge);
      }
    }
  }
);
  getToplevel().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;
  NamedObj linkHead=(NamedObj)link.getHead();
  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");
  String relationName="String_Node_Str";
  try {
    _unlinkMoML(moml,linkHead,linkTail,linkRelation);
    relationName=_linkMoML(moml,failmoml,(NamedObj)newLinkHead,linkTail);
  }
 catch (  Exception ex) {
    throw new GraphException(ex);
  }
  moml.append("String_Node_Str");
  failmoml.append("String_Node_Str");
  final String relationNameToAdd=relationName;
  ChangeRequest request=new MoMLChangeRequest(PtolemyGraphModel.this,getToplevel(),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 ChangeListener(){
    public void changeFailed(    ChangeRequest change,    Exception exception){
      _linkSet.remove(link);
      link.setHead(null);
      link.setTail(null);
      link.setRelation(null);
      ChangeRequest request=new MoMLChangeRequest(PtolemyGraphModel.this,getToplevel(),failmoml.toString());
      getToplevel().requestChange(request);
    }
    public void changeExecuted(    ChangeRequest change){
      if (GraphUtilities.isPartiallyContainedEdge(edge,getRoot(),PtolemyGraphModel.this)) {
        _linkSet.add(edge);
      }
 else {
        _linkSet.remove(edge);
      }
    }
  }
);
  getToplevel().requestChange(request);
}