Program: 75012
Project: 75012
Buggy source:
/** 
 * Return the scheduling sequence. If the schedule exist in the cache (schedules are identified by the rate signatures of ports), then return the corresponding schedule in the cache. Otherwise, compute the schedule and return it.
 * @return A schedule of the deeply contained opaque entitiesin the firing order.
 * @exception NotSchedulableException If the super class throws it.
 * @exception IllegalActionException If the super class throws it.
 */
protected Schedule _getSchedule() throws NotSchedulableException, IllegalActionException {
  Schedule schedule;
  if (_inputPortList == null || _workspaceVersion != workspace().getVersion()) {
    _inputPortList=_getInputPortList();
  }
  if (_outputPortList == null || _workspaceVersion != workspace().getVersion()) {
    _outputPortList=_getOutputPortList();
  }
  _workspaceVersion=workspace().getVersion();
  StringBuffer rates=new StringBuffer();
  Iterator inputPorts=_inputPortList.iterator();
  while (inputPorts.hasNext()) {
    IOPort inputPort=(IOPort)inputPorts.next();
    int rate=DFUtilities.getTokenConsumptionRate(inputPort);
    rates.append(rate);
  }
  Iterator outputPorts=_outputPortList.iterator();
  while (outputPorts.hasNext()) {
    IOPort outputPort=(IOPort)outputPorts.next();
    int rate=DFUtilities.getTokenProductionRate(outputPort);
    rates.append(rate);
    int initRate=DFUtilities.getTokenInitProduction(outputPort);
    rates.append(rate);
  }
  String rateKey=rates.toString();
  if (_scheduleCache.containsKey(rateKey)) {
    schedule=(Schedule)_scheduleCache.get(rateKey);
    if (!rateKey.equals(_mostRecentRates)) {
      _mostRecentRates=rateKey;
      if (_cacheSize > 0) {
        _scheduleKeyList.remove(rateKey);
        _scheduleKeyList.add(0,rateKey);
      }
      Map externalRates=(Map)_externalRatesCache.get(rateKey);
      _saveContainerRates(externalRates);
    }
  }
 else {
    _mostRecentRates=rateKey;
    if (_cacheSize > 0) {
      while (_scheduleKeyList.size() >= _cacheSize) {
        Object object=_scheduleKeyList.get(_cacheSize - 1);
        _scheduleKeyList.remove(_cacheSize - 1);
        _scheduleCache.remove(object);
        _externalRatesCache.remove(object);
        _scheduleKeyList.add(0,rateKey);
      }
    }
    schedule=super._getSchedule();
    _scheduleCache.put(rateKey,schedule);
    Map externalRates=getExternalRates();
    _externalRatesCache.put(rateKey,externalRates);
  }
  setValid(true);
  return schedule;
}

Fixed version (ground truth):
/** 
 * Return the scheduling sequence. If the schedule exist in the cache (schedules are identified by the rate signatures of ports), then return the corresponding schedule in the cache. Otherwise, compute the schedule and return it.
 * @return A schedule of the deeply contained opaque entitiesin the firing order.
 * @exception NotSchedulableException If the super class throws it.
 * @exception IllegalActionException If the super class throws it.
 */
protected Schedule _getSchedule() throws NotSchedulableException, IllegalActionException {
  Schedule schedule;
  if (_inputPortList == null || _workspaceVersion != workspace().getVersion()) {
    _inputPortList=_getInputPortList();
  }
  if (_outputPortList == null || _workspaceVersion != workspace().getVersion()) {
    _outputPortList=_getOutputPortList();
  }
  _workspaceVersion=workspace().getVersion();
  StringBuffer rates=new StringBuffer();
  Iterator inputPorts=_inputPortList.iterator();
  while (inputPorts.hasNext()) {
    IOPort inputPort=(IOPort)inputPorts.next();
    int rate=DFUtilities.getTokenConsumptionRate(inputPort);
    rates.append(rate);
  }
  Iterator outputPorts=_outputPortList.iterator();
  while (outputPorts.hasNext()) {
    IOPort outputPort=(IOPort)outputPorts.next();
    int rate=DFUtilities.getTokenProductionRate(outputPort);
    rates.append(rate);
    int initRate=DFUtilities.getTokenInitProduction(outputPort);
    rates.append(rate);
  }
  String rateKey=rates.toString();
  if (_scheduleCache.containsKey(rateKey)) {
    schedule=(Schedule)_scheduleCache.get(rateKey);
    if (!rateKey.equals(_mostRecentRates)) {
      _mostRecentRates=rateKey;
      if (_cacheSize > 0) {
        _scheduleKeyList.remove(rateKey);
        _scheduleKeyList.add(0,rateKey);
      }
      Map externalRates=(Map)_externalRatesCache.get(rateKey);
      _saveContainerRates(externalRates);
    }
  }
 else {
    _mostRecentRates=rateKey;
    if (_cacheSize > 0) {
      while (_scheduleKeyList.size() >= _cacheSize) {
        Object key=_scheduleKeyList.get(_cacheSize - 1);
        _scheduleKeyList.remove(_cacheSize - 1);
        _scheduleCache.remove(key);
        _externalRatesCache.remove(key);
      }
      _scheduleKeyList.add(0,rateKey);
    }
    schedule=super._getSchedule();
    _scheduleCache.put(rateKey,schedule);
    Map externalRates=getExternalRates();
    _externalRatesCache.put(rateKey,externalRates);
  }
  setValid(true);
  return schedule;
}