Program: 73720
Project: 73720
Buggy source:
/** 
 * Unregister a "published port" coming from a publisher. The name is the name being used in the matching process to match publisher and subscriber. A subscriber interested in the output of this publisher uses the same name. This registration process of publisher typically happens before the model is preinitialized, for example when opening the model. The subscribers will look for publishers during the preinitialization phase.
 * @param name The name is being used in the matching processto match publisher and subscriber. This will be the port that should be removed
 * @param publisherPort The publisher port.
 * @param global If true, unregister the port all the way up the hierarchy.
 */
public void unregisterPublisherPort(String name,IOPort publisherPort,boolean global){
  NamedObj container=getContainer();
  if (!isOpaque() && container instanceof CompositeActor && !((CompositeActor)container).isClassDefinition()) {
    ((CompositeActor)container).unregisterPublisherPort(name,publisherPort);
  }
 else {
    if (_publishedPorts != null) {
      List<IOPort> ports=_publishedPorts.get(name);
      ports.remove(publisherPort);
      if (ports.isEmpty()) {
        _publishedPorts.remove(name);
      }
    }
    if (_publisherRelations != null) {
      IORelation relation=_publisherRelations.get(name);
      if (relation != null) {
        try {
          relation.setContainer(null);
        }
 catch (        IllegalActionException e) {
          throw new IllegalStateException(e);
        }
catch (        NameDuplicationException e) {
          throw new IllegalStateException(e);
        }
        _publisherRelations.remove(name);
      }
    }
    if (global && container instanceof CompositeActor) {
      ((CompositeActor)container).unregisterPublisherPort(name,publisherPort,global);
    }
  }
}

Fixed version (ground truth):
/** 
 * Unregister a "published port" coming from a publisher. The name is the name being used in the matching process to match publisher and subscriber. A subscriber interested in the output of this publisher uses the same name. This registration process of publisher typically happens before the model is preinitialized, for example when opening the model. The subscribers will look for publishers during the preinitialization phase.
 * @param name The name is being used in the matching processto match publisher and subscriber. This will be the port that should be removed
 * @param publisherPort The publisher port.
 * @param global If true, unregister the port all the way up the hierarchy.
 */
public void unregisterPublisherPort(String name,IOPort publisherPort,boolean global){
  NamedObj container=getContainer();
  if (!isOpaque() && container instanceof CompositeActor && !((CompositeActor)container).isClassDefinition()) {
    ((CompositeActor)container).unregisterPublisherPort(name,publisherPort);
  }
 else {
    if (_publishedPorts != null) {
      List<IOPort> ports=_publishedPorts.get(name);
      ports.remove(publisherPort);
      if (ports.isEmpty()) {
        _publishedPorts.remove(name);
      }
    }
    if (_publisherRelations != null) {
      IORelation relation=_publisherRelations.get(name);
      if (relation != null) {
        try {
          relation.setContainer(null);
          notifyConnectivityChange();
        }
 catch (        IllegalActionException e) {
          throw new IllegalStateException(e);
        }
catch (        NameDuplicationException e) {
          throw new IllegalStateException(e);
        }
        _publisherRelations.remove(name);
      }
    }
    if (global && container instanceof CompositeActor) {
      ((CompositeActor)container).unregisterPublisherPort(name,publisherPort,global);
    }
  }
}