Program: 74837
Project: 74837
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;
  DEEvent nextEvent=null;
  while (!_stopRequested) {
    if (_stopWhenQueueIsEmpty) {
      if (_eventQueue.isEmpty()) {
        break;
      }
    }
    if (!_isTopLevel()) {
      if (_eventQueue.isEmpty()) {
        break;
      }
 else {
        nextEvent=_eventQueue.get();
        if ((nextEvent.timeStamp().compareTo(getModelTime()) < 0)) {
          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().equals(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=_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=_eventQueue.get();
            currentTime=lastFoundEvent.timeStamp();
            long elapsedTime=System.currentTimeMillis() - _realStartTime;
            double elapsedTimeInSeconds=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 {
                _workspace.wait(_eventQueue,timeToWait);
              }
 catch (              InterruptedException ex) {
              }
            }
          }
        }
      }
synchronized (_eventQueue) {
        lastFoundEvent=_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       if (actorToFire == getContainer()) {
        Actor actor=nextEvent.actor();
        if (actor == actorToFire && nextEvent.hasTheSameTagAs(lastFoundEvent)) {
          _eventQueue.take();
        }
 else {
          break;
        }
      }
 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;
  DEEvent nextEvent=null;
  while (!_stopRequested) {
    if (_stopWhenQueueIsEmpty) {
      if (_eventQueue.isEmpty()) {
        break;
      }
    }
    if (!_isTopLevel()) {
      if (_eventQueue.isEmpty()) {
        break;
      }
 else {
        nextEvent=_eventQueue.get();
        if ((nextEvent.timeStamp().compareTo(getModelTime()) < 0)) {
          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().equals(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=_eventQueue.get();
      }
    }
    if (nextEvent == null) {
      throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
    }
    if (actorToFire == null) {
      Time currentTime;
      if (_synchronizeToRealTime) {
synchronized (_eventQueue) {
          while (!_stopRequested) {
            lastFoundEvent=_eventQueue.get();
            currentTime=lastFoundEvent.timeStamp();
            long elapsedTime=System.currentTimeMillis() - _realStartTime;
            double elapsedTimeInSeconds=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 {
                _workspace.wait(_eventQueue,timeToWait);
              }
 catch (              InterruptedException ex) {
              }
            }
          }
        }
      }
synchronized (_eventQueue) {
        lastFoundEvent=_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       if (actorToFire == getContainer()) {
        Actor actor=nextEvent.actor();
        if (actor == actorToFire && nextEvent.hasTheSameTagAs(lastFoundEvent)) {
          _eventQueue.take();
        }
 else {
          break;
        }
      }
 else {
        break;
      }
    }
  }
  return actorToFire;
}