Program: 72386
Project: 72386
Buggy source:
/** 
 * RTI service for event-based federate (NER or NERA) is used for proposing a time to advance to.
 * @param proposedTime time stamp of lastFoundEvent
 * @return
 */
private Time _eventsBasedTimeAdvance(Time proposedTime) throws IllegalActionException, InvalidFederationTime, FederationTimeAlreadyPassed, TimeAdvanceAlreadyInProgress, FederateNotExecutionMember, SaveInProgress, EnableTimeRegulationPending, EnableTimeConstrainedPending, RestoreInProgress, RTIinternalError, ConcurrentAccessAttempted, SpecifiedSaveLabelDoesNotExist {
  CertiLogicalTime certiProposedTime=_convertToCertiLogicalTime(proposedTime);
  String proposedTimeInString=_printTimes(proposedTime);
  proposedTime=new Time(_director,Double.parseDouble(proposedTimeInString));
  _storeTimes("String_Node_Str" + proposedTimeInString + "String_Node_Str");
  if (_hlaLookAHead > 0) {
    if (_debugging) {
      _debug("String_Node_Str" + proposedTimeInString + "String_Node_Str"+ proposedTimeInString+ "String_Node_Str"+ "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
    }
    _rtia.nextEventRequest(certiProposedTime);
    _numberOfNERs++;
    _timeOfTheLastAdvanceRequest=System.nanoTime();
  }
 else {
    if (_debugging) {
      _debug("String_Node_Str" + proposedTimeInString + "String_Node_Str"+ proposedTimeInString+ "String_Node_Str"+ "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
    }
    _rtia.nextEventRequestAvailable(certiProposedTime);
    _numberOfNERs++;
    _timeOfTheLastAdvanceRequest=System.nanoTime();
    _federateAmbassador.timeAdvanceGrant=false;
    while (!(_federateAmbassador.timeAdvanceGrant)) {
      if (_debugging) {
        _debug("String_Node_Str" + proposedTimeInString + "String_Node_Str"+ proposedTimeInString+ "String_Node_Str"+ "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
      }
      _rtia.tick2();
      _numberOfTicks2++;
      _numberOfTicks.set(_numberOfTAGs,_numberOfTicks.get(_numberOfTAGs) + 1);
      ;
    }
    if (_debugging) {
      if (_debugging) {
        _debug("String_Node_Str" + proposedTimeInString + "String_Node_Str"+ proposedTimeInString+ "String_Node_Str"+ "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
      }
    }
    _rtia.nextEventRequest(certiProposedTime);
    _numberOfNERs++;
    _timeOfTheLastAdvanceRequest=System.nanoTime();
  }
  _federateAmbassador.timeAdvanceGrant=false;
  int cntTick=0;
  while (!(_federateAmbassador.timeAdvanceGrant)) {
    if (_debugging) {
      _debug("String_Node_Str" + proposedTimeInString + "String_Node_Str"+ proposedTimeInString+ "String_Node_Str"+ "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
    }
    _rtia.tick2();
    _numberOfTicks2++;
    cntTick++;
  }
  _numberOfTicks.set(_numberOfTAGs,_numberOfTicks.get(_numberOfTAGs) + cntTick);
  if (_debugging) {
    _debug("String_Node_Str" + proposedTimeInString + "String_Node_Str"+ proposedTimeInString+ "String_Node_Str");
  }
  if (cntTick != 1) {
    _putReflectedAttributesOnHlaSubscribers();
    try {
      CertiLogicalTime hlaTimeGranted=(CertiLogicalTime)_federateAmbassador.logicalTimeHLA;
      Time breakpoint=_convertToPtolemyTime(hlaTimeGranted);
      if (_debugging) {
        _debug("String_Node_Str" + proposedTimeInString + "String_Node_Str"+ proposedTimeInString+ "String_Node_Str"+ hlaTimeGranted+ "String_Node_Str"+ _printTimes(breakpoint));
      }
      proposedTime=breakpoint;
    }
 catch (    IllegalActionException e) {
      throw new IllegalActionException(this,e,"String_Node_Str");
    }
  }
  return proposedTime;
}

Fixed version (ground truth):
/** 
 * RTI service for event-based federate (NER or NERA) is used for proposing a time to advance to.
 * @param proposedTime time stamp of lastFoundEvent
 * @return
 */
private Time _eventsBasedTimeAdvance(Time proposedTime) throws IllegalActionException, InvalidFederationTime, FederationTimeAlreadyPassed, TimeAdvanceAlreadyInProgress, FederateNotExecutionMember, SaveInProgress, EnableTimeRegulationPending, EnableTimeConstrainedPending, RestoreInProgress, RTIinternalError, ConcurrentAccessAttempted, SpecifiedSaveLabelDoesNotExist {
  CertiLogicalTime certiProposedTime=_convertToCertiLogicalTime(proposedTime);
  String proposedTimeInString=_printTimes(proposedTime);
  proposedTime=new Time(_director,Double.parseDouble(proposedTimeInString));
  _storeTimes("String_Node_Str" + proposedTimeInString + "String_Node_Str");
  if (_hlaLookAHead > 0) {
    if (_debugging) {
      _debug("String_Node_Str" + proposedTimeInString + "String_Node_Str"+ proposedTimeInString+ "String_Node_Str"+ "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
    }
    _rtia.nextEventRequest(certiProposedTime);
    _numberOfNERs++;
    _timeOfTheLastAdvanceRequest=System.nanoTime();
  }
 else {
    if (_debugging) {
      _debug("String_Node_Str" + proposedTimeInString + "String_Node_Str"+ proposedTimeInString+ "String_Node_Str"+ "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
    }
    _rtia.nextEventRequestAvailable(certiProposedTime);
    _numberOfNERs++;
    _timeOfTheLastAdvanceRequest=System.nanoTime();
    _federateAmbassador.timeAdvanceGrant=false;
    while (!(_federateAmbassador.timeAdvanceGrant)) {
      if (_debugging) {
        _debug("String_Node_Str" + proposedTimeInString + "String_Node_Str"+ proposedTimeInString+ "String_Node_Str"+ "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
      }
      _rtia.tick2();
      _numberOfTicks2++;
      _numberOfTicks.set(_numberOfTAGs,_numberOfTicks.get(_numberOfTAGs) + 1);
      ;
    }
    if (_debugging) {
      _debug("String_Node_Str" + proposedTimeInString + "String_Node_Str"+ proposedTimeInString+ "String_Node_Str"+ "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
    }
    _rtia.nextEventRequest(certiProposedTime);
    _numberOfNERs++;
    _timeOfTheLastAdvanceRequest=System.nanoTime();
  }
  _federateAmbassador.timeAdvanceGrant=false;
  int cntTick=0;
  while (!(_federateAmbassador.timeAdvanceGrant)) {
    if (_debugging) {
      _debug("String_Node_Str" + proposedTimeInString + "String_Node_Str"+ proposedTimeInString+ "String_Node_Str"+ "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
    }
    _rtia.tick2();
    _numberOfTicks2++;
    cntTick++;
  }
  _numberOfTicks.set(_numberOfTAGs,_numberOfTicks.get(_numberOfTAGs) + cntTick);
  if (_debugging) {
    _debug("String_Node_Str" + proposedTimeInString + "String_Node_Str"+ proposedTimeInString+ "String_Node_Str");
  }
  if (cntTick != 1) {
    _putReflectedAttributesOnHlaSubscribers();
    try {
      CertiLogicalTime hlaTimeGranted=(CertiLogicalTime)_federateAmbassador.logicalTimeHLA;
      Time breakpoint=_convertToPtolemyTime(hlaTimeGranted);
      if (_debugging) {
        _debug("String_Node_Str" + proposedTimeInString + "String_Node_Str"+ proposedTimeInString+ "String_Node_Str"+ hlaTimeGranted+ "String_Node_Str"+ _printTimes(breakpoint));
      }
      proposedTime=breakpoint;
    }
 catch (    IllegalActionException e) {
      throw new IllegalActionException(this,e,"String_Node_Str");
    }
  }
  return proposedTime;
}