Program: 74282
Project: 74282
Buggy source:
/** 
 * Fire an entry in the event queue. If the entry contains information about a scheduled actor, then the prefire(), fire() and postfire() methods of the actor are called. If the entry contains an event, then the event is processed (which means more events may be placed into the event queue, or existing ones may be cancelled). If the event has a refinement, the the refinement is also fired.
 * @param timedEvent The entry in the event queue.
 * @return True if an event is processed or an actor is fired, or false ifthe prefire() method of the actor returns false.
 * @exception IllegalActionException If firing the actor or processing theevent throws it, or if the contents of the given entry cannot be recognized.
 */
private boolean _fire(TimedEvent timedEvent) throws IllegalActionException {
  ERGController controller=getController();
  Object contents=timedEvent.contents;
  if (contents instanceof Actor) {
    return _fireActor((Actor)contents,timedEvent);
  }
 else   if (contents instanceof Event) {
    Event event=(Event)contents;
    _eventQueue.remove(timedEvent);
    _refinementQueue.remove(timedEvent);
    for (    Set<TimedEvent> set : _eventsListeningToPorts.values()) {
      set.remove(timedEvent);
    }
    for (    Set<TimedEvent> set : _eventsListeningToVariables.values()) {
      set.remove(timedEvent);
    }
    controller._setCurrentEvent(event);
    RefiringData data;
    if (timedEvent.data == null) {
      data=event.fire(timedEvent.arguments);
    }
 else {
      data=event.refire(timedEvent.arguments,timedEvent.data);
    }
    if (data != null) {
      _fireAt(event,getModelTime().add(data.getTimeAdvance()),timedEvent.arguments,null,data,timedEvent.priority);
    }
    boolean scheduled=false;
    if (timedEvent.data == null) {
      TypedActor[] refinements=event.getRefinement();
      if (refinements != null) {
        for (        TypedActor refinement : refinements) {
          if (!event._isActiveRefinement(refinement)) {
            continue;
          }
          scheduled=true;
          if (refinement instanceof ERGController) {
            ((ERGController)refinement).director._insertInitialEvents();
            fireAt(refinement,getModelTime());
          }
 else {
            _fireActor(refinement,null);
          }
        }
      }
    }
    boolean scheduleNext=!scheduled && data == null;
    if (scheduleNext) {
      if (event.isFinalEvent()) {
        _eventQueue.clear();
        _refinementQueue.clear();
      }
 else {
        event.scheduleEvents();
      }
    }
    return true;
  }
 else {
    throw new InternalErrorException(this,null,"String_Node_Str" + "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Fire an entry in the event queue. If the entry contains information about a scheduled actor, then the prefire(), fire() and postfire() methods of the actor are called. If the entry contains an event, then the event is processed (which means more events may be placed into the event queue, or existing ones may be cancelled). If the event has a refinement, the the refinement is also fired.
 * @param timedEvent The entry in the event queue.
 * @return True if an event is processed or an actor is fired, or false ifthe prefire() method of the actor returns false.
 * @exception IllegalActionException If firing the actor or processing theevent throws it, or if the contents of the given entry cannot be recognized.
 */
private boolean _fire(TimedEvent timedEvent) throws IllegalActionException {
  _eventQueue.remove(timedEvent);
  _refinementQueue.remove(timedEvent);
  ERGController controller=getController();
  Object contents=timedEvent.contents;
  if (contents instanceof Actor) {
    return _fireActor((Actor)contents,timedEvent);
  }
 else   if (contents instanceof Event) {
    Event event=(Event)contents;
    for (    Set<TimedEvent> set : _eventsListeningToPorts.values()) {
      set.remove(timedEvent);
    }
    for (    Set<TimedEvent> set : _eventsListeningToVariables.values()) {
      set.remove(timedEvent);
    }
    controller._setCurrentEvent(event);
    RefiringData data;
    if (timedEvent.data == null) {
      data=event.fire(timedEvent.arguments);
    }
 else {
      data=event.refire(timedEvent.arguments,timedEvent.data);
    }
    if (data != null) {
      _fireAt(event,getModelTime().add(data.getTimeAdvance()),timedEvent.arguments,null,data,timedEvent.priority);
    }
    boolean scheduled=false;
    if (timedEvent.data == null) {
      TypedActor[] refinements=event.getRefinement();
      if (refinements != null) {
        for (        TypedActor refinement : refinements) {
          if (!event._isActiveRefinement(refinement)) {
            continue;
          }
          if (refinement instanceof ERGController || !_initializedRefinements.contains(refinement)) {
            refinement.initialize();
            _initializedRefinements.add(refinement);
          }
 else {
            _fireActor(refinement,null);
          }
          scheduled=true;
        }
      }
    }
    boolean scheduleNext=!scheduled && data == null;
    if (scheduleNext) {
      if (event.isFinalEvent()) {
        _eventQueue.clear();
        _refinementQueue.clear();
      }
 else {
        event.scheduleEvents();
      }
    }
    return true;
  }
 else {
    throw new InternalErrorException(this,null,"String_Node_Str" + "String_Node_Str");
  }
}