Program: 74324
Project: 74324
Buggy source:
/** 
 * Return next event that can be fired out of a list of events that are safe to fire. This is the case if - the list of eventsToFire is empty - the next event that should be fired has to be fired at real time = model time and real time is not there yet - the next event that could be fired has a wcet > next real time event.
 * @param actorsFiring Actors currently in execution.
 * @param eventsToFire Events that are safe to fire.
 * @param nextRealTimeEvent Smallest time stamp of events that have to be fired at model time = real time.
 * @param physicalTime Current physical time of the model.
 * @return The next event that can be fired.
 * @exception IllegalActionException Thrown if an execution was missed.
 */
public TimedEvent getNextEventToFire(Queue<TimedEvent> actorsFiring,List<TimedEvent> eventsToFire,Time nextRealTimeEvent,Time physicalTime) throws IllegalActionException {
  if (eventsToFire.size() == 0) {
    return null;
  }
  Collections.sort(eventsToFire,new WCETComparator(physicalTime));
  TimedEvent event;
  int index=0;
  while (index < eventsToFire.size()) {
    event=eventsToFire.get(index);
    Actor actorToFire=event.contents instanceof IOPort ? (Actor)((IOPort)event.contents).getContainer() : (Actor)event.contents;
    if (actorsFiring.size() > 0 && !_actorPreempts((Actor)actorsFiring.peek().contents,actorToFire,event.timeStamp,physicalTime)) {
      index++;
      continue;
    }
    if (PtidesActorProperties.mustBeFiredAtRealTime(event.contents)) {
      if (physicalTime.compareTo(event.timeStamp) > 0) {
        _displaySchedule(actorToFire,event.timeStamp.getDoubleValue(),ScheduleEventType.MISSEDEXECUTION);
        throw new IllegalActionException("String_Node_Str");
      }
 else       if (physicalTime.compareTo(event.timeStamp) < 0) {
        index++;
        continue;
      }
    }
    return new TimedEvent(event.timeStamp,actorToFire);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Return next event that can be fired out of a list of events that are safe to fire. This is the case if - the list of eventsToFire is empty - the next event that should be fired has to be fired at real time = model time and real time is not there yet - the next event that could be fired has a wcet > next real time event.
 * @param actorsFiring Actors currently in execution.
 * @param eventsToFire Events that are safe to fire.
 * @param nextRealTimeEvent Smallest time stamp of events that have to be fired at model time = real time.
 * @param physicalTime Current physical time of the model.
 * @return The next event that can be fired.
 * @exception IllegalActionException Thrown if an execution was missed.
 */
public TimedEvent getNextEventToFire(Queue<TimedEvent> actorsFiring,List<TimedEvent> eventsToFire,Time nextRealTimeEvent,Time physicalTime) throws IllegalActionException {
  if (eventsToFire.size() == 0) {
    return null;
  }
  Collections.sort(eventsToFire,new WCETComparator(physicalTime));
  TimedEvent event;
  int index=0;
  while (index < eventsToFire.size()) {
    event=eventsToFire.get(index);
    Actor actorToFire=event.contents instanceof IOPort ? (Actor)((IOPort)event.contents).getContainer() : (Actor)event.contents;
    if (actorsFiring.size() > 0 && !_actorPreempts((Actor)actorsFiring.peek().contents,actorToFire,event.timeStamp,physicalTime)) {
      index++;
      continue;
    }
    if (PtidesActorProperties.mustBeFiredAtRealTime(event.contents)) {
      if (physicalTime.compareTo(event.timeStamp) > 0) {
        _displaySchedule(actorToFire,event.timeStamp.getDoubleValue(),ScheduleEventType.MISSEDEXECUTION);
        throw new IllegalActionException("String_Node_Str" + event);
      }
 else       if (physicalTime.compareTo(event.timeStamp) < 0) {
        index++;
        continue;
      }
    }
    eventsToFire.remove(event);
    return new TimedEvent(event.timeStamp,actorToFire);
  }
  return null;
}