Program: 75152
Project: 75152
Buggy source:
/** 
 * Dequeue the events that have the smallest tag from the event queue. Return their destination actor. Advance the model tag to their tag. If the timestamp of the smallest tag is greater than the stop time then return null. If there are no events in the event queue, and the stopWhenQueueIsEmpty parameter is set to true, then return null. Both cases will have the effect of stopping the simulation. <p> If the stopWhenQueueIsEmpty parameter is false and the queue is empty, then stall the current thread by calling wait() on the _eventQueue until there are new events available.  If the synchronizeToRealTime parameter is true, then this method may suspend the calling thread by using Object.wait(long) to let elapsed real time catch up with the current model time.
 * @return The next actor to be fired, which can be null.
 * @exception IllegalActionException If event queue is not ready, oran event is missed, or time is set backwards.
 */
private Actor _getNextActorToFire() throws IllegalActionException {
  if (_eventQueue == null) {
    throw new IllegalActionException("String_Node_Str");
  }
  Actor actorToFire=null;
  DEEvent lastFoundEvent=null, nextEvent=null;
  while (!_stopRequested) {
    if (_stopWhenQueueIsEmpty) {
      if (_eventQueue.isEmpty()) {
        break;
      }
    }
    if (!_isTopLevel()) {
      if (_eventQueue.isEmpty()) {
        break;
      }
 else {
        nextEvent=(DEEvent)_eventQueue.get();
        if (nextEvent.timeStamp().compareTo(getModelTime()) < 0) {
          nextEvent=null;
          throw new IllegalActionException("String_Node_Str" + nextEvent.timeStamp() + "String_Node_Str"+ nextEvent.microstep()+ "String_Node_Str"+ getModelTime()+ "String_Node_Str"+ _microstep+ "String_Node_Str");
        }
        if ((nextEvent.timeStamp().compareTo(getModelTime()) > 0)) {
          nextEvent=null;
          break;
        }
      }
    }
 else {
      if (_eventQueue.isEmpty()) {
        if (actorToFire != null || (getModelTime() == getModelStopTime())) {
          break;
        }
      }
      while (_eventQueue.isEmpty() && !_stopRequested) {
        if (_debugging) {
          _debug("String_Node_Str");
        }
        Thread.yield();
synchronized (_eventQueue) {
          if (_eventQueue.isEmpty()) {
            try {
              workspace().wait(_eventQueue);
            }
 catch (            InterruptedException e) {
              break;
            }
          }
        }
      }
      if (_eventQueue.isEmpty()) {
        break;
      }
 else {
        nextEvent=(DEEvent)_eventQueue.get();
      }
    }
    if (nextEvent == null) {
      throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
    }
    if (actorToFire == null) {
      Time currentTime;
      if (_synchronizeToRealTime) {
synchronized (_eventQueue) {
          while (true) {
            lastFoundEvent=(DEEvent)_eventQueue.get();
            currentTime=lastFoundEvent.timeStamp();
            long elapsedTime=System.currentTimeMillis() - _realStartTime;
            double elapsedTimeInSeconds=((double)elapsedTime) / 1000.0;
            if (currentTime.getDoubleValue() <= elapsedTimeInSeconds) {
              break;
            }
            long timeToWait=(long)(currentTime.subtract(elapsedTimeInSeconds).getDoubleValue() * 1000.0);
            if (timeToWait > 0) {
              if (_debugging) {
                _debug("String_Node_Str" + timeToWait);
              }
              try {
                _eventQueue.wait(timeToWait);
              }
 catch (              InterruptedException ex) {
              }
            }
          }
        }
      }
synchronized (_eventQueue) {
        lastFoundEvent=(DEEvent)_eventQueue.take();
        currentTime=lastFoundEvent.timeStamp();
        actorToFire=lastFoundEvent.actor();
        if (_disabledActors != null && _disabledActors.contains(actorToFire)) {
          if (_debugging) {
            _debug("String_Node_Str",((Nameable)actorToFire).getFullName());
          }
          actorToFire=null;
          continue;
        }
        setModelTime(currentTime);
        _microstep=lastFoundEvent.microstep();
      }
      if (currentTime.compareTo(getModelStopTime()) > 0) {
        if (_debugging) {
          _debug("String_Node_Str");
        }
        _exceedStopTime=true;
        return null;
      }
    }
 else {
      if (nextEvent.hasTheSameTagAndDepthAs(lastFoundEvent)) {
        _eventQueue.take();
      }
 else {
        break;
      }
    }
  }
  return actorToFire;
}

Fixed version (ground truth):
/** 
 * Dequeue the events that have the smallest tag from the event queue. Return their destination actor. Advance the model tag to their tag. If the timestamp of the smallest tag is greater than the stop time then return null. If there are no events in the event queue, and the stopWhenQueueIsEmpty parameter is set to true, then return null. Both cases will have the effect of stopping the simulation. <p> If the stopWhenQueueIsEmpty parameter is false and the queue is empty, then stall the current thread by calling wait() on the _eventQueue until there are new events available.  If the synchronizeToRealTime parameter is true, then this method may suspend the calling thread by using Object.wait(long) to let elapsed real time catch up with the current model time.
 * @return The next actor to be fired, which can be null.
 * @exception IllegalActionException If event queue is not ready, oran event is missed, or time is set backwards.
 */
private Actor _getNextActorToFire() throws IllegalActionException {
  if (_eventQueue == null) {
    throw new IllegalActionException("String_Node_Str");
  }
  Actor actorToFire=null;
  DEEvent lastFoundEvent=null, nextEvent=null;
  while (!_stopRequested) {
    if (_stopWhenQueueIsEmpty) {
      if (_eventQueue.isEmpty()) {
        break;
      }
    }
    if (!_isTopLevel()) {
      if (_eventQueue.isEmpty()) {
        break;
      }
 else {
        nextEvent=(DEEvent)_eventQueue.get();
        if (nextEvent.timeStamp().compareTo(getModelTime()) < 0 || (nextEvent.timeStamp().equals(getModelTime()) && (nextEvent.microstep() < _microstep))) {
          throw new IllegalActionException("String_Node_Str" + nextEvent.timeStamp() + "String_Node_Str"+ nextEvent.microstep()+ "String_Node_Str"+ getModelTime()+ "String_Node_Str"+ _microstep+ "String_Node_Str");
        }
        if ((nextEvent.timeStamp().compareTo(getModelTime()) > 0)) {
          nextEvent=null;
          break;
        }
      }
    }
 else {
      if (_eventQueue.isEmpty()) {
        if (actorToFire != null || (getModelTime() == getModelStopTime())) {
          break;
        }
      }
      while (_eventQueue.isEmpty() && !_stopRequested) {
        if (_debugging) {
          _debug("String_Node_Str");
        }
        Thread.yield();
synchronized (_eventQueue) {
          if (_eventQueue.isEmpty()) {
            try {
              workspace().wait(_eventQueue);
            }
 catch (            InterruptedException e) {
              break;
            }
          }
        }
      }
      if (_eventQueue.isEmpty()) {
        break;
      }
 else {
        nextEvent=(DEEvent)_eventQueue.get();
      }
    }
    if (nextEvent == null) {
      throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
    }
    if (actorToFire == null) {
      Time currentTime;
      if (_synchronizeToRealTime) {
synchronized (_eventQueue) {
          while (true) {
            lastFoundEvent=(DEEvent)_eventQueue.get();
            currentTime=lastFoundEvent.timeStamp();
            long elapsedTime=System.currentTimeMillis() - _realStartTime;
            double elapsedTimeInSeconds=((double)elapsedTime) / 1000.0;
            if (currentTime.getDoubleValue() <= elapsedTimeInSeconds) {
              break;
            }
            long timeToWait=(long)(currentTime.subtract(elapsedTimeInSeconds).getDoubleValue() * 1000.0);
            if (timeToWait > 0) {
              if (_debugging) {
                _debug("String_Node_Str" + timeToWait);
              }
              try {
                _eventQueue.wait(timeToWait);
              }
 catch (              InterruptedException ex) {
              }
            }
          }
        }
      }
synchronized (_eventQueue) {
        lastFoundEvent=(DEEvent)_eventQueue.take();
        currentTime=lastFoundEvent.timeStamp();
        actorToFire=lastFoundEvent.actor();
        if (_disabledActors != null && _disabledActors.contains(actorToFire)) {
          if (_debugging) {
            _debug("String_Node_Str",((Nameable)actorToFire).getFullName());
          }
          actorToFire=null;
          continue;
        }
        setModelTime(currentTime);
        _microstep=lastFoundEvent.microstep();
      }
      if (currentTime.compareTo(getModelStopTime()) > 0) {
        if (_debugging) {
          _debug("String_Node_Str");
        }
        _exceedStopTime=true;
        return null;
      }
    }
 else {
      if (nextEvent.hasTheSameTagAndDepthAs(lastFoundEvent)) {
        _eventQueue.take();
      }
 else {
        break;
      }
    }
  }
  return actorToFire;
}