Program: 73149
Project: 73149
Buggy source:
/** 
 * Find resource scheduler for actor and request scheduling. TODO: This method could be moved to the Director class such that all other MoCs can do resource usage simulation.
 * @param actor The actor to be scheduled.
 * @return Time until next scheduling action or 0.0 if actor can start execution.
 * @throws IllegalActionException
 */
public Time scheduleActor(Actor actor) throws IllegalActionException {
  if (_schedulerForActor == null) {
    _schedulerForActor=new HashMap();
  }
  Object object=_schedulerForActor.get(actor);
  if (!_schedulerForActor.containsKey(actor)) {
    if (object == null) {
      List attributeList=((NamedObj)actor).attributeList();
      if (attributeList.size() > 0) {
        for (int i=0; i < attributeList.size(); i++) {
          Object attr=attributeList.get(i);
          if (attr instanceof Parameter) {
            Token paramToken=((Parameter)attr).getToken();
            if (paramToken instanceof ObjectToken) {
              Object paramObject=((ObjectToken)paramToken).getValue();
              if (paramObject instanceof ResourceScheduler) {
                ResourceScheduler scheduler=(ResourceScheduler)paramObject;
                _schedulerForActor.put(actor,scheduler);
                object=scheduler;
                break;
              }
            }
          }
        }
        if (!_schedulerForActor.containsKey(actor)) {
          _schedulerForActor.put(actor,null);
        }
      }
    }
  }
  if (object != null) {
    return ((ResourceScheduler)object).schedule(actor,getEnvironmentTime());
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Find resource scheduler for actor and request scheduling. TODO: This method could be moved to the Director class such that all other MoCs can do resource usage simulation.
 * @param actor The actor to be scheduled.
 * @return Time until next scheduling action or 0.0 if actor can start execution.
 * @throws IllegalActionException
 */
public Time scheduleActor(Actor actor) throws IllegalActionException {
  if (_schedulerForActor == null) {
    _schedulerForActor=new HashMap();
  }
  Object object=_schedulerForActor.get(actor);
  if (!_schedulerForActor.containsKey(actor)) {
    if (object == null) {
      List attributeList=((NamedObj)actor).attributeList();
      if (attributeList.size() > 0) {
        for (int i=0; i < attributeList.size(); i++) {
          Object attr=attributeList.get(i);
          if (attr instanceof Parameter) {
            Token paramToken=((Parameter)attr).getToken();
            if (paramToken instanceof ObjectToken) {
              Object paramObject=((ObjectToken)paramToken).getValue();
              if (paramObject instanceof ResourceScheduler) {
                ResourceScheduler scheduler=(ResourceScheduler)paramObject;
                if (_resourceSchedulers.contains(scheduler)) {
                  _schedulerForActor.put(actor,scheduler);
                  object=scheduler;
                  break;
                }
              }
            }
          }
        }
        if (!_schedulerForActor.containsKey(actor)) {
          _schedulerForActor.put(actor,null);
        }
      }
    }
  }
  if (object != null) {
    return ((ResourceScheduler)object).schedule(actor,getEnvironmentTime());
  }
 else {
    return null;
  }
}