Program: 75833
Project: 75833
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=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=SDFScheduler.getTokenConsumptionRate(inputPort);
      rates=rates + String.valueOf(rate);
    }
    Iterator outputPorts=_outputPortList.iterator();
    while (inputPorts.hasNext()) {
      IOPort outputPort=(IOPort)outputPorts.next();
      int rate=SDFScheduler.getTokenProductionRate(outputPort);
      rates=rates + String.valueOf(rate);
    }
    if (_debug_info) {
      System.out.println("String_Node_Str" + rates);
    }
    String rateKey=rates;
    int cacheSize=((IntToken)(scheduleCacheSize.getToken())).intValue();
    if (_scheduleCache.containsKey(rateKey)) {
      if (_debug_info) {
        System.out.println(getName() + "String_Node_Str");
      }
      if (cacheSize > 0) {
        _scheduleKeyList.remove(rateKey);
        _scheduleKeyList.add(0,rateKey);
      }
      schedule=(Schedule)_scheduleCache.get(rateKey);
    }
 else {
      if (_debug_info) {
        System.out.println(getName() + "String_Node_Str");
      }
      if (cacheSize > 0) {
        while (_scheduleKeyList.size() >= cacheSize) {
          Object object=_scheduleKeyList.get(cacheSize - 1);
          _scheduleKeyList.remove(cacheSize - 1);
          _scheduleCache.remove(object);
        }
        _scheduleKeyList.add(0,rateKey);
      }
      schedule=scheduler.getSchedule();
      _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=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=SDFScheduler.getTokenConsumptionRate(inputPort);
      rates=rates + String.valueOf(rate);
    }
    Iterator outputPorts=_outputPortList.iterator();
    while (inputPorts.hasNext()) {
      IOPort outputPort=(IOPort)outputPorts.next();
      int rate=SDFScheduler.getTokenProductionRate(outputPort);
      rates=rates + String.valueOf(rate);
    }
    if (_debug_info) {
      System.out.println("String_Node_Str" + rates);
    }
    String rateKey=rates;
    int cacheSize=((IntToken)(scheduleCacheSize.getToken())).intValue();
    if (cacheSize != _cacheSize) {
      _scheduleCache=new HashMap();
      _scheduleKeyList=new ArrayList(cacheSize);
      _cacheSize=cacheSize;
    }
    if (_scheduleCache.containsKey(rateKey)) {
      if (_debug_info) {
        System.out.println(getName() + "String_Node_Str");
      }
      if (cacheSize > 0) {
        _scheduleKeyList.remove(rateKey);
        _scheduleKeyList.add(0,rateKey);
      }
      schedule=(Schedule)_scheduleCache.get(rateKey);
    }
 else {
      if (_debug_info) {
        System.out.println(getName() + "String_Node_Str");
      }
      if (cacheSize > 0) {
        while (_scheduleKeyList.size() >= cacheSize) {
          Object object=_scheduleKeyList.get(cacheSize - 1);
          _scheduleKeyList.remove(cacheSize - 1);
          _scheduleCache.remove(object);
        }
        _scheduleKeyList.add(0,rateKey);
      }
      schedule=scheduler.getSchedule();
      _scheduleCache.put(rateKey,schedule);
    }
  }
  return schedule;
}