Program: 72712
Project: 72712
Buggy source:
/** 
 * Execute all set actions contained by the transition chosen from the current state. Change current state to the destination state of the last of these chosen transitions. If the new current state is a transient state that has a chosen transition emanating from it, then also execute the set actions on that transition. Reset the refinement of the destination state if the <i>reset</i> parameter of the chosen transition is true.
 * @param inPreinitialize If true, then only set the currentstate after following immediate transitions. Note that the guards on the immediate transitions need to be evaluatable.
 * @param inInitialize True when this method is calledfrom initialize or preinitialize, in which case, firing and initializing refinements is not allowed; note that the refinements will be initialized by the initialize method, but this prevents them from being initialized more than once. This could be important if, for example, the refinement produces an output during initialize in a domain where outputs are consumed, such as SDF.
 * @exception IllegalActionException If any commit action throws it,or the last chosen transition does not have a destination state.
 */
private void _commitLastChosenTransition(boolean inPreinitialize,boolean inInitialize) throws IllegalActionException {
  Transition currentTransition=_lastChosenTransitions.get(_currentState);
  if (currentTransition == null) {
    return;
  }
  _lastTakenTransitions.add(currentTransition);
  _lastChosenTransitions.remove(_currentState);
  if (_debugging) {
    _debug("String_Node_Str",currentTransition.getFullName() + "String_Node_Str" + getDirector().getModelTime());
    _debug("String_Node_Str" + currentTransition.guardExpression.getExpression());
  }
  if (currentTransition.destinationState() == null) {
    throw new IllegalActionException(this,currentTransition,"String_Node_Str" + "String_Node_Str");
  }
  Iterator actions=currentTransition.commitActionList().iterator();
  while (actions.hasNext() && !_stopRequested) {
    Action action=(Action)actions.next();
    action.execute();
  }
  State nextState=currentTransition.destinationState();
  if (_lastChosenTransitions.get(nextState) == null) {
    if (!currentTransition.isHistory() && !inPreinitialize && !inInitialize) {
      _initializeRefinements(nextState);
    }
  }
  boolean stateChanged=_currentState != currentTransition.destinationState();
  _schedule(nextState,getDirector().getModelTime());
  _currentState=nextState;
  if (stateChanged) {
    _oldThreshold=0.0;
  }
  if (_debugging) {
    _debug(new StateEvent(this,_currentState));
  }
  _timeOfNextTimeoutExpiration=null;
  _timeEnteredCurrentState=getDirector().getModelTime();
  if (((BooleanToken)_currentState.isFinalState.getToken()).booleanValue()) {
    _reachedFinalState=true;
  }
  _setCurrentConnectionMap();
  boolean stateDependent=((BooleanToken)stateDependentCausality.getToken()).booleanValue();
  if (stateDependent && stateChanged) {
    ChangeRequest request=new ChangeRequest(this,"String_Node_Str",false){
      protected void _execute(){
        getDirector().invalidateSchedule();
      }
    }
;
    request.setPersistent(false);
    requestChange(request);
  }
  if (!inPreinitialize) {
    getDirector().fireAtCurrentTime(this);
  }
  if (!_reachedFinalState && stateChanged) {
    _commitLastChosenTransition(inPreinitialize,inInitialize);
  }
 else {
    _lastChosenTransitions.clear();
  }
}

Fixed version (ground truth):
/** 
 * Execute all set actions contained by the transition chosen from the current state. Change current state to the destination state of the last of these chosen transitions. If the new current state is a transient state that has a chosen transition emanating from it, then also execute the set actions on that transition. Reset the refinement of the destination state if the <i>reset</i> parameter of the chosen transition is true.
 * @param inPreinitialize If true, then only set the currentstate after following immediate transitions. Note that the guards on the immediate transitions need to be evaluatable.
 * @param inInitialize True when this method is calledfrom initialize or preinitialize, in which case, firing and initializing refinements is not allowed; note that the refinements will be initialized by the initialize method, but this prevents them from being initialized more than once. This could be important if, for example, the refinement produces an output during initialize in a domain where outputs are consumed, such as SDF.
 * @exception IllegalActionException If any commit action throws it,or the last chosen transition does not have a destination state.
 */
private void _commitLastChosenTransition(boolean inPreinitialize,boolean inInitialize) throws IllegalActionException {
  Transition currentTransition=_lastChosenTransitions.get(_currentState);
  if (currentTransition == null) {
    return;
  }
  _lastTakenTransitions.add(currentTransition);
  _lastChosenTransitions.remove(_currentState);
  if (_debugging) {
    _debug("String_Node_Str",currentTransition.getFullName() + "String_Node_Str" + getDirector().getModelTime());
    _debug("String_Node_Str" + currentTransition.guardExpression.getExpression());
  }
  if (currentTransition.destinationState() == null) {
    throw new IllegalActionException(this,currentTransition,"String_Node_Str" + "String_Node_Str");
  }
  Iterator actions=currentTransition.commitActionList().iterator();
  while (actions.hasNext() && !_stopRequested) {
    Action action=(Action)actions.next();
    action.execute();
  }
  State nextState=currentTransition.destinationState();
  if (_lastChosenTransitions.get(nextState) == null) {
    if (!currentTransition.isHistory() && !inPreinitialize && !inInitialize) {
      _initializeRefinements(nextState);
    }
  }
  boolean stateChanged=_currentState != currentTransition.destinationState();
  _schedule(nextState,getExecutiveDirector().getModelTime());
  System.out.println(getExecutiveDirector().getModelTime() + "String_Node_Str" + nextState.getName());
  _currentState=nextState;
  if (stateChanged) {
    _oldThreshold=0.0;
  }
  if (_debugging) {
    _debug(new StateEvent(this,_currentState));
  }
  _timeOfNextTimeoutExpiration=null;
  _timeEnteredCurrentState=getDirector().getModelTime();
  if (((BooleanToken)_currentState.isFinalState.getToken()).booleanValue()) {
    _reachedFinalState=true;
  }
  _setCurrentConnectionMap();
  boolean stateDependent=((BooleanToken)stateDependentCausality.getToken()).booleanValue();
  if (stateDependent && stateChanged) {
    ChangeRequest request=new ChangeRequest(this,"String_Node_Str",false){
      protected void _execute(){
        getDirector().invalidateSchedule();
      }
    }
;
    request.setPersistent(false);
    requestChange(request);
  }
  if (!inPreinitialize) {
    getDirector().fireAtCurrentTime(this);
  }
  if (!_reachedFinalState && stateChanged) {
    _commitLastChosenTransition(inPreinitialize,inInitialize);
  }
 else {
    _lastChosenTransitions.clear();
  }
}