Program: 72928
Project: 72928
Buggy source:
/** 
 * Return true if the director is ready to fire. This method is called by the container of this director to determine whether the director is ready to execute. It does <i>not</i> call prefire() on the contained actors.  If this director is not at the top level of the hierarchy, and the current time of the enclosing model is greater than the current time of this director, then this base class updates current time to match that of the enclosing model.  <p> In this base class, assume that the director is always ready to be fired, and so return true.  Domain directors should probably override this method to provide domain-specific operation.  However, they should call super.prefire() if they wish to propagate time as done here.
 * @return True.
 * @exception IllegalActionException Not thrown in this base class.
 */
public boolean prefire() throws IllegalActionException {
  _postfireReturns=true;
  _prefire=super.prefire();
  if (_resourceScheduling && _prefire) {
    Iterator firings=null;
    if (_savedSchedule == null) {
      Scheduler scheduler=getScheduler();
      Schedule schedule=scheduler.getSchedule();
      _savedSchedule=schedule;
      _savedSchedulePosition=0;
      firings=schedule.firingIterator();
    }
 else {
      firings=_savedSchedule.firingIterator();
      for (int i=0; i < _savedSchedulePosition; i++) {
        firings.next();
      }
    }
    Firing firing=null;
    while ((_savedIterationCount > 0 || firings.hasNext()) && !_stopRequested) {
      if (firing == null || _savedIterationCount == 0) {
        firing=(Firing)firings.next();
      }
      Actor actor=firing.getActor();
      if (_currentlyExecuting) {
        _prefire=false;
        return false;
      }
      if (!_actorFinished) {
        boolean finished=_schedule(actor,getModelTime());
        if (!finished) {
          _currentlyExecuting=true;
          _prefire=false;
          return false;
        }
      }
      _currentlyExecuting=false;
      _actorFinished=false;
      if (_savedIterationCount == 0) {
        _savedIterationCount=firing.getIterationCount();
      }
      _savedIterationCount--;
      if (_savedIterationCount == 0) {
        _savedSchedulePosition++;
      }
    }
    if (_savedSchedule.size() <= _savedSchedulePosition) {
      _savedSchedule=null;
    }
  }
  return _prefire;
}

Fixed version (ground truth):
/** 
 * Return true if the director is ready to fire. This method is called by the container of this director to determine whether the director is ready to execute. It does <i>not</i> call prefire() on the contained actors.  If this director is not at the top level of the hierarchy, and the current time of the enclosing model is greater than the current time of this director, then this base class updates current time to match that of the enclosing model.  <p> In this base class, assume that the director is always ready to be fired, and so return true.  Domain directors should probably override this method to provide domain-specific operation.  However, they should call super.prefire() if they wish to propagate time as done here.
 * @return True.
 * @exception IllegalActionException Not thrown in this base class.
 */
public boolean prefire() throws IllegalActionException {
  _postfireReturns=true;
  _prefire=super.prefire();
  if (_resourceScheduling && _prefire) {
    Iterator firings=null;
    if (_savedSchedule == null) {
      Scheduler scheduler=getScheduler();
      Schedule schedule=scheduler.getSchedule();
      _savedSchedule=schedule;
      _savedSchedulePosition=0;
      firings=schedule.firingIterator();
    }
 else {
      firings=_savedSchedule.firingIterator();
      for (int i=0; i < _savedSchedulePosition; i++) {
        firings.next();
      }
    }
    Firing firing=null;
    while ((_savedIterationCount > 0 || firings.hasNext()) && !_stopRequested) {
      if (firing == null || _savedIterationCount == 0) {
        firing=(Firing)firings.next();
      }
      Actor actor=firing.getActor();
      if (!_actorFinished) {
        boolean finished=_schedule(actor,getModelTime());
        if (!finished) {
          _currentlyExecuting=true;
          _prefire=false;
          return false;
        }
      }
      _currentlyExecuting=false;
      _actorFinished=false;
      if (_savedIterationCount == 0) {
        _savedIterationCount=firing.getIterationCount();
      }
      _savedIterationCount--;
      if (_savedIterationCount == 0) {
        _savedSchedulePosition++;
      }
    }
    if (_savedSchedule.size() <= _savedSchedulePosition) {
      _savedSchedule=null;
    }
  }
  return _prefire;
}