Program: 75571
Project: 75571
Buggy source:
/** 
 * Return the scheduling sequence.  An exception will be thrown if the graph is not schedulable.  This occurs in the following circumstances: <ul> <li>The graph is not a connected graph. <li>The graph is not acyclic <li>Multiple output ports are connected to the same broadcast relation. (equivalent to a non-deterministic merge) </ul>
 * @return A Schedule type of the deeply contained opaque entitiesin the firing order.
 * @exception NotSchedulableException If the CompositeActor is notschedulable.
 */
protected Schedule _getSchedule(){
  DirectedAcyclicGraph dag=new DirectedAcyclicGraph();
  GRDirector director=(GRDirector)getContainer();
  if (director == null) {
    return null;
  }
  CompositeActor container=(CompositeActor)(director.getContainer());
  if (container == null) {
    return null;
  }
  CompositeActor castContainer=(CompositeActor)container;
  int count=0;
  List entities=castContainer.deepEntityList();
  Iterator actors=entities.iterator();
  int actorCount=entities.size();
  while (actors.hasNext()) {
    Actor actor=(Actor)actors.next();
    dag.addNodeWeight(actor);
  }
  actors=castContainer.deepEntityList().iterator();
  while (actors.hasNext()) {
    Actor actor=(Actor)actors.next();
    LinkedList successors=new LinkedList();
    Iterator outports=actor.outputPortList().iterator();
    while (outports.hasNext()) {
      IOPort outPort=(IOPort)outports.next();
      int referenceDepth=outPort.depthInHierarchy();
      Iterator inPorts=outPort.deepConnectedInPortList().iterator();
      while (inPorts.hasNext()) {
        IOPort inPort=(IOPort)inPorts.next();
        if (inPort.depthInHierarchy() < referenceDepth) {
          continue;
        }
        Actor post=(Actor)inPort.getContainer();
        if (!successors.contains(post)) {
          successors.addLast(post);
        }
      }
    }
    Iterator succeedingActors=successors.iterator();
    while (succeedingActors.hasNext()) {
      Actor connectedActor=(Actor)succeedingActors.next();
      dag.addEdge(actor,connectedActor);
    }
  }
  if (!dag.isAcyclic()) {
    Object[] cycleNodes=dag.cycleNodes();
    StringBuffer names=new StringBuffer();
    for (int i=0; i < cycleNodes.length; i++) {
      if (cycleNodes[i] instanceof Nameable) {
        if (i > 0)         names.append("String_Node_Str");
        names.append(((Nameable)cycleNodes[i]).getFullName());
      }
    }
    throw new NotSchedulableException(this,"String_Node_Str" + names.toString());
  }
  if (dag.top() == null) {
  }
  Schedule schedule=new Schedule();
  Object[] sorted=dag.topologicalSort();
  for (int counter=0; counter < actorCount; counter++) {
    Firing firing=new Firing();
    schedule.add(firing);
    firing.setActor((Actor)sorted[counter]);
  }
  setValid(true);
  return schedule;
}

Fixed version (ground truth):
/** 
 * Return the scheduling sequence.  An exception will be thrown if the graph is not schedulable.  This occurs in the following circumstances: <ul> <li>The graph is not a connected graph. <li>The graph is not acyclic <li>Multiple output ports are connected to the same broadcast relation. (equivalent to a non-deterministic merge) </ul>
 * @return A Schedule type of the deeply contained opaque entitiesin the firing order.
 * @exception NotSchedulableException If the CompositeActor is notschedulable.
 */
protected Schedule _getSchedule(){
  DirectedAcyclicGraph dag=new DirectedAcyclicGraph();
  GRDirector director=(GRDirector)getContainer();
  if (director == null) {
    return null;
  }
  int referenceDepth=director.depthInHierarchy();
  CompositeActor container=(CompositeActor)(director.getContainer());
  if (container == null) {
    return null;
  }
  CompositeActor castContainer=(CompositeActor)container;
  int count=0;
  List entities=castContainer.deepEntityList();
  Iterator actors=entities.iterator();
  int actorCount=entities.size();
  while (actors.hasNext()) {
    Actor actor=(Actor)actors.next();
    dag.addNodeWeight(actor);
  }
  actors=castContainer.deepEntityList().iterator();
  while (actors.hasNext()) {
    Actor actor=(Actor)actors.next();
    Set successors=new HashSet();
    Iterator outports=actor.outputPortList().iterator();
    while (outports.hasNext()) {
      IOPort outPort=(IOPort)outports.next();
      Iterator sinkPorts=outPort.sinkPortList().iterator();
      while (sinkPorts.hasNext()) {
        IOPort sinkPort=(IOPort)sinkPorts.next();
        if (sinkPort.isOutput()) {
          continue;
        }
        Actor sinkActor=(Actor)sinkPort.getContainer();
        successors.add(sinkActor);
      }
    }
    Iterator succeedingActors=successors.iterator();
    while (succeedingActors.hasNext()) {
      Actor connectedActor=(Actor)succeedingActors.next();
      dag.addEdge(actor,connectedActor);
    }
  }
  if (!dag.isAcyclic()) {
    Object[] cycleNodes=dag.cycleNodes();
    StringBuffer names=new StringBuffer();
    for (int i=0; i < cycleNodes.length; i++) {
      if (cycleNodes[i] instanceof Nameable) {
        if (i > 0)         names.append("String_Node_Str");
        names.append(((Nameable)cycleNodes[i]).getFullName());
      }
    }
    throw new NotSchedulableException(this,"String_Node_Str" + names.toString());
  }
  if (dag.top() == null) {
  }
  Schedule schedule=new Schedule();
  Object[] sorted=dag.topologicalSort();
  for (int counter=0; counter < actorCount; counter++) {
    Firing firing=new Firing();
    schedule.add(firing);
    firing.setActor((Actor)sorted[counter]);
  }
  if (_debugging) {
    _debug("String_Node_Str");
    _debug(schedule.toString());
  }
  setValid(true);
  return schedule;
}