Program: 72425
Project: 72425
Buggy source:
/** 
 * Propose a time to advance to. This method is the one implementing the TimeRegulator interface and using the HLA/CERTI Time Management services (if required). Following HLA and CERTI recommendations, if the Time Management is required then we have the following behavior: Case 1: If lookahead = 0 -a) if time-stepped Federate, then the timeAdvanceRequestAvailable() (TARA) service is used; -b) if event-based Federate, then the nextEventRequestAvailable() (NERA) service is used Case 2: If lookahead &gt; 0 -c) if time-stepped Federate, then timeAdvanceRequest() (TAR) is used; -d) if event-based Federate, then the nextEventRequest() (NER) is used; Otherwise the proposedTime is returned. NOTE: For the Ptolemy II - HLA/CERTI cooperation the default (and correct) behavior is the case 1 and CERTI has to be compiled with the option "CERTI_USE_NULL_PRIME_MESSAGE_PROTOCOL".
 * @param proposedTime The proposed time.
 * @return The proposed time or a smaller time.
 * @exception IllegalActionException If this attribute is notcontained by an Actor.
 */
@Override public Time proposeTime(Time proposedTime) throws IllegalActionException {
  if (_debugging) {
    _debug(this.getDisplayName() + "String_Node_Str");
  }
  Time currentTime=_getModelTime();
  proposedTime=new Time(_director,_getDoubleOfTime(proposedTime));
  if (proposedTime.compareTo(_stopTime) == 1) {
    if (_debugging) {
      _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str");
    }
    return _stopTime;
  }
  if (_rtia == null) {
    if (_debugging) {
      _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str");
    }
    return proposedTime;
  }
  if (currentTime.equals(proposedTime)) {
    if (_debugging) {
      _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ _getDoubleOfTime(currentTime)+ "String_Node_Str");
    }
    try {
      _rtia.tick();
      if (_timeOfTheLastAdvanceRequest > 0) {
        _numberOfTicks.set(_numberOfTAGs,_numberOfTicks.get(_numberOfTAGs) + 1);
      }
 else {
        _numberOfOtherTicks++;
      }
    }
 catch (    ConcurrentAccessAttempted e) {
      throw new IllegalActionException(this,e,"String_Node_Str");
    }
catch (    RTIinternalError e) {
      throw new IllegalActionException(this,e,"String_Node_Str");
    }
    return currentTime;
  }
  if (_isTimeRegulator && _isTimeConstrained) {
synchronized (this) {
      try {
        if (_eventBased) {
          return _eventsBasedTimeAdvance(proposedTime);
        }
 else {
          return _timeSteppedBasedTimeAdvance(proposedTime);
        }
      }
 catch (      InvalidFederationTime e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      FederationTimeAlreadyPassed e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      TimeAdvanceAlreadyInProgress e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      EnableTimeRegulationPending e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      EnableTimeConstrainedPending e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      FederateNotExecutionMember e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      SaveInProgress e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      RestoreInProgress e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      RTIinternalError e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      ConcurrentAccessAttempted e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      NoSuchElementException e) {
        if (_debugging) {
          _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
        }
        return proposedTime;
      }
catch (      SpecifiedSaveLabelDoesNotExist ex) {
        Logger.getLogger(HlaManager.class.getName()).log(Level.SEVERE,null,ex);
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Propose a time to advance to. This method is the one implementing the TimeRegulator interface and using the HLA/CERTI Time Management services (if required). Following HLA and CERTI recommendations, if the Time Management is required then we have the following behavior: Case 1: If lookahead = 0 -a) if time-stepped Federate, then the timeAdvanceRequestAvailable() (TARA) service is used; -b) if event-based Federate, then the nextEventRequestAvailable() (NERA) service is used Case 2: If lookahead &gt; 0 -c) if time-stepped Federate, then timeAdvanceRequest() (TAR) is used; -d) if event-based Federate, then the nextEventRequest() (NER) is used; Otherwise the proposedTime is returned. NOTE: For the Ptolemy II - HLA/CERTI cooperation the default (and correct) behavior is the case 1 and CERTI has to be compiled with the option "CERTI_USE_NULL_PRIME_MESSAGE_PROTOCOL".
 * @param proposedTime The proposed time.
 * @return The proposed time or a smaller time.
 * @exception IllegalActionException If this attribute is notcontained by an Actor.
 */
@Override public Time proposeTime(Time proposedTime) throws IllegalActionException {
  if (_debugging) {
    _debug(this.getDisplayName() + "String_Node_Str");
  }
  Time currentTime=_getModelTime();
  proposedTime=new Time(_director,_getDoubleOfTime(proposedTime));
  if (proposedTime.compareTo(_stopTime) > 0) {
    if (_debugging) {
      _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str");
    }
    return _stopTime;
  }
  if (_rtia == null) {
    if (_debugging) {
      _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str");
    }
    return proposedTime;
  }
  if (currentTime.equals(proposedTime)) {
    if (_debugging) {
      _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ _getDoubleOfTime(currentTime)+ "String_Node_Str");
    }
    try {
      _rtia.tick();
      if (_timeOfTheLastAdvanceRequest > 0) {
        _numberOfTicks.set(_numberOfTAGs,_numberOfTicks.get(_numberOfTAGs) + 1);
      }
 else {
        _numberOfOtherTicks++;
      }
    }
 catch (    ConcurrentAccessAttempted e) {
      throw new IllegalActionException(this,e,"String_Node_Str");
    }
catch (    RTIinternalError e) {
      throw new IllegalActionException(this,e,"String_Node_Str");
    }
    return currentTime;
  }
  if (_isTimeRegulator && _isTimeConstrained) {
synchronized (this) {
      try {
        if (_eventBased) {
          return _eventsBasedTimeAdvance(proposedTime);
        }
 else {
          return _timeSteppedBasedTimeAdvance(proposedTime);
        }
      }
 catch (      InvalidFederationTime e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      FederationTimeAlreadyPassed e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      TimeAdvanceAlreadyInProgress e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      EnableTimeRegulationPending e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      EnableTimeConstrainedPending e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      FederateNotExecutionMember e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      SaveInProgress e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      RestoreInProgress e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      RTIinternalError e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      ConcurrentAccessAttempted e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      NoSuchElementException e) {
        if (_debugging) {
          _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
        }
        return proposedTime;
      }
catch (      SpecifiedSaveLabelDoesNotExist ex) {
        Logger.getLogger(HlaManager.class.getName()).log(Level.SEVERE,null,ex);
      }
    }
  }
  return null;
}