Program: 74193
Project: 74193
Buggy source:
/** 
 * Specify the container, adding the relation to the list of relations in the container. If this relation already has a container, remove it from that container first.  Otherwise, remove it from the list of objects in the workspace. If the argument is null, then unlink the ports from the relation, remove it from its container, and add it to the list of objects in the workspace. If the relation is already contained by the container, do nothing. <p> The container must be an instance of CompositeActor or null, otherwise an exception is thrown. Derived classes may further constrain the class of the container to a subclass of CompositeActor. <p> This method invalidates the schedule and resolved types of the director of the container, if there is one. <p> This method is write-synchronized on the workspace.
 * @param container The proposed container.
 * @exception IllegalActionException If the container is not aCompositeActor or null, or this entity and the container are not in the same workspace.
 * @exception NameDuplicationException If the name collides with a namealready on the relations list of the container.
 */
public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException {
  if (!(container instanceof CompositeActor) && (container != null)) {
    throw new IllegalActionException(this,container,"String_Node_Str");
  }
  Nameable oldContainer=getContainer();
  if (oldContainer instanceof CompositeActor) {
    Director director=((CompositeActor)oldContainer).getDirector();
    if (director != null) {
      director.invalidateSchedule();
      director.invalidateResolvedTypes();
    }
  }
  if (container instanceof CompositeActor) {
    Director director=((CompositeActor)container).getDirector();
    if (director != null) {
      director.invalidateSchedule();
      director.invalidateResolvedTypes();
    }
  }
  super.setContainer(container);
}

Fixed version (ground truth):
/** 
 * Specify the container, adding the relation to the list of relations in the container. If this relation already has a container, remove it from that container first.  Otherwise, remove it from the list of objects in the workspace. If the argument is null, then unlink the ports from the relation, remove it from its container, and add it to the list of objects in the workspace. If the relation is already contained by the container, do nothing. <p> The container must be an instance of CompositeActor or null, otherwise an exception is thrown. Derived classes may further constrain the class of the container to a subclass of CompositeActor. <p> This method invalidates the schedule and resolved types of the director of the container, if there is one. <p> This method is write-synchronized on the workspace.
 * @param container The proposed container.
 * @exception IllegalActionException If the container is not aCompositeActor or null, or this entity and the container are not in the same workspace.
 * @exception NameDuplicationException If the name collides with a namealready on the relations list of the container.
 */
public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException {
  if (!(container instanceof CompositeActor) && (container != null)) {
    throw new IllegalActionException(this,container,"String_Node_Str");
  }
  Nameable oldContainer=getContainer();
  if (oldContainer instanceof CompositeActor) {
    Director director=((CompositeActor)oldContainer).getDirector();
    if (director != null) {
      director.invalidateSchedule();
      director.invalidateResolvedTypes();
    }
  }
  if (container != null) {
    Director director=((CompositeActor)container).getDirector();
    if (director != null) {
      director.invalidateSchedule();
      director.invalidateResolvedTypes();
    }
  }
  super.setContainer(container);
}