Program: 75076
Project: 75076
Buggy source:
/** 
 * Return the scheduling sequence as an instance of Schedule. For efficiency, this method maintains a schedule cache and will attempt to return a cached version of the schedule. If the cache does not contain the schedule for the current hdf graph, then the schedule will be computed by calling the getSchedule() method of the SDFScheduler. <p> The schedule cache uses a least-recently-used replacement policy. The size of the cache is specified by the scheduleCacheSize parameter. The default cache size is 100.
 * @return The Schedule for the current hdf graph.
 * @exception IllegalActionException If there is a problem gettingthe schedule.
 */
public Schedule getSchedule() throws IllegalActionException {
  Scheduler scheduler=getScheduler();
  Schedule schedule;
  if (isScheduleValid()) {
    schedule=((SDFScheduler)scheduler).getSchedule();
  }
 else {
    if (_inputPortList == null) {
      _inputPortList=_getInputPortList();
    }
    if (_outputPortList == null) {
      _outputPortList=_getOutputPortList();
    }
    Iterator inputPorts=_inputPortList.iterator();
    String rates=new String();
    while (inputPorts.hasNext()) {
      IOPort inputPort=(IOPort)inputPorts.next();
      int rate=DFUtilities.getTokenConsumptionRate(inputPort);
      rates=rates + String.valueOf(rate);
    }
    Iterator outputPorts=_outputPortList.iterator();
    while (outputPorts.hasNext()) {
      IOPort outputPort=(IOPort)outputPorts.next();
      int rate=DFUtilities.getTokenProductionRate(outputPort);
      rates=rates + String.valueOf(rate);
      int initRate=DFUtilities.getTokenInitProduction(outputPort);
      rates=rates + String.valueOf(rate);
    }
    String rateKey=rates;
    int cacheSize=((IntToken)(scheduleCacheSize.getToken())).intValue();
    if (cacheSize != _cacheSize) {
      _scheduleCache=new HashMap();
      _scheduleKeyList=new ArrayList(cacheSize);
      _cacheSize=cacheSize;
      _externalRatesCache=new TreeMap();
      _externalRatesKeyList=new ArrayList(cacheSize);
    }
    if (rateKey == _mostRecentRates) {
      schedule=((SDFScheduler)scheduler).getSchedule();
    }
 else     if (_scheduleCache.containsKey(rateKey)) {
      _mostRecentRates=rateKey;
      if (cacheSize > 0) {
        _scheduleKeyList.remove(rateKey);
        _externalRatesKeyList.remove(rateKey);
        _scheduleKeyList.add(0,rateKey);
        _externalRatesKeyList.add(0,rateKey);
      }
      schedule=(Schedule)_scheduleCache.get(rateKey);
      Map externalRates=(Map)_externalRatesCache.get(rateKey);
      ((SDFScheduler)scheduler).setContainerRates(externalRates);
    }
 else {
      _mostRecentRates=rateKey;
      if (cacheSize > 0) {
        while (_scheduleKeyList.size() >= cacheSize) {
          Object object=_scheduleKeyList.get(cacheSize - 1);
          _scheduleKeyList.remove(cacheSize - 1);
          _externalRatesKeyList.remove(cacheSize - 1);
          _scheduleCache.remove(object);
          _externalRatesCache.remove(object);
        }
        _scheduleKeyList.add(0,rateKey);
        _externalRatesKeyList.add(0,rateKey);
      }
      schedule=((SDFScheduler)scheduler).getSchedule();
      Map externalRates=((SDFScheduler)scheduler).getExternalRates();
      _externalRatesCache.put(rateKey,externalRates);
      _scheduleCache.put(rateKey,schedule);
    }
  }
  return schedule;
}

Fixed version (ground truth):
/** 
 * Return the scheduling sequence as an instance of Schedule. For efficiency, this method maintains a schedule cache and will attempt to return a cached version of the schedule. If the cache does not contain the schedule for the current hdf graph, then the schedule will be computed by calling the getSchedule() method of the SDFScheduler. <p> The schedule cache uses a least-recently-used replacement policy. The size of the cache is specified by the scheduleCacheSize parameter. The default cache size is 100.
 * @return The Schedule for the current hdf graph.
 * @exception IllegalActionException If there is a problem gettingthe schedule.
 */
public Schedule getSchedule() throws IllegalActionException {
  Scheduler scheduler=getScheduler();
  Schedule schedule;
  if (isScheduleValid()) {
    schedule=((SDFScheduler)scheduler).getSchedule();
  }
 else {
    if (_inputPortList == null) {
      _inputPortList=_getInputPortList();
    }
    if (_outputPortList == null) {
      _outputPortList=_getOutputPortList();
    }
    Iterator inputPorts=_inputPortList.iterator();
    String rates="String_Node_Str";
    while (inputPorts.hasNext()) {
      IOPort inputPort=(IOPort)inputPorts.next();
      int rate=DFUtilities.getTokenConsumptionRate(inputPort);
      rates=rates + String.valueOf(rate);
    }
    Iterator outputPorts=_outputPortList.iterator();
    while (outputPorts.hasNext()) {
      IOPort outputPort=(IOPort)outputPorts.next();
      int rate=DFUtilities.getTokenProductionRate(outputPort);
      rates=rates + String.valueOf(rate);
      int initRate=DFUtilities.getTokenInitProduction(outputPort);
      rates=rates + String.valueOf(rate);
    }
    String rateKey=rates;
    int cacheSize=((IntToken)(scheduleCacheSize.getToken())).intValue();
    if (cacheSize != _cacheSize) {
      _scheduleCache=new HashMap();
      _scheduleKeyList=new ArrayList(cacheSize);
      _cacheSize=cacheSize;
      _externalRatesCache=new TreeMap();
      _externalRatesKeyList=new ArrayList(cacheSize);
    }
    if (rateKey == _mostRecentRates) {
      schedule=((SDFScheduler)scheduler).getSchedule();
    }
 else     if (_scheduleCache.containsKey(rateKey)) {
      _mostRecentRates=rateKey;
      if (cacheSize > 0) {
        _scheduleKeyList.remove(rateKey);
        _externalRatesKeyList.remove(rateKey);
        _scheduleKeyList.add(0,rateKey);
        _externalRatesKeyList.add(0,rateKey);
      }
      schedule=(Schedule)_scheduleCache.get(rateKey);
      Map externalRates=(Map)_externalRatesCache.get(rateKey);
      ((SDFScheduler)scheduler).setContainerRates(externalRates);
    }
 else {
      _mostRecentRates=rateKey;
      if (cacheSize > 0) {
        while (_scheduleKeyList.size() >= cacheSize) {
          Object object=_scheduleKeyList.get(cacheSize - 1);
          _scheduleKeyList.remove(cacheSize - 1);
          _externalRatesKeyList.remove(cacheSize - 1);
          _scheduleCache.remove(object);
          _externalRatesCache.remove(object);
        }
        _scheduleKeyList.add(0,rateKey);
        _externalRatesKeyList.add(0,rateKey);
      }
      schedule=((SDFScheduler)scheduler).getSchedule();
      Map externalRates=((SDFScheduler)scheduler).getExternalRates();
      _externalRatesCache.put(rateKey,externalRates);
      _scheduleCache.put(rateKey,schedule);
    }
  }
  return schedule;
}