Program: 73619
Project: 73619
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.
 * @throws NameDuplicationException 
 * @throws IllegalActionException 
 */
public void unregisterPublisherPort(String name,IOPort publisherPort,boolean global) throws IllegalActionException, NameDuplicationException {
  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);
      if (ports != null) {
        ports.remove(publisherPort);
        if (ports.isEmpty()) {
          _publishedPorts.remove(name);
        }
      }
    }
    List connectedPorts=publisherPort.connectedPortList();
    if (_publisherRelations != null) {
      IORelation relation=_publisherRelations.get(name);
      if (relation != null) {
        relation.setContainer(null);
        notifyConnectivityChange();
        _publisherRelations.remove(name);
      }
    }
    if (global && container instanceof CompositeActor) {
      for (      Object port : connectedPorts) {
        IOPort publishedPort=(IOPort)port;
        if (publishedPort.isOutput()) {
          ((CompositeActor)container).unregisterPublisherPort(name,publishedPort,global);
          publishedPort.setContainer(null);
        }
      }
    }
  }
}

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.
 * @throws NameDuplicationException 
 * @throws IllegalActionException 
 */
public void unregisterPublisherPort(String name,IOPort publisherPort,boolean global) throws IllegalActionException, NameDuplicationException {
  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);
      if (ports != null) {
        ports.remove(publisherPort);
        if (ports.isEmpty()) {
          _publishedPorts.remove(name);
        }
      }
    }
    if (_publisherRelations != null) {
      IORelation relation=_publisherRelations.get(name);
      if (relation != null) {
        if (global && container instanceof CompositeActor) {
          for (          Object port : relation.linkedPortList(publisherPort)) {
            IOPort publishedPort=(IOPort)port;
            if (publishedPort.isOutput()) {
              ((CompositeActor)container).unregisterPublisherPort(name,publishedPort,global);
              publishedPort.setContainer(null);
            }
          }
        }
        relation.setContainer(null);
        notifyConnectivityChange();
        _publisherRelations.remove(name);
      }
    }
  }
}