Program: 74183
Project: 74183
Buggy source:
/** 
 * Return the executive director. If the current controller is the top-level controller of an ERG modal model, then the executive director is its director (returned by   {@link #getDirector()}). Otherwise, the executive director is the director of the ERG controller at a higher level in the refinement hierarchy.
 * @return The executive director.
 */
public Director getExecutiveDirector(){
  Workspace workspace=workspace();
  try {
    workspace.getReadAccess();
    if (_executiveDirectorVersion != workspace.getVersion()) {
      ERGModalModel modalModel=(ERGModalModel)getContainer();
      if (modalModel.getController() == this) {
        _executiveDirector=super.getDirector();
      }
 else {
        _executiveDirector=null;
        for (        Object atomicEntity : modalModel.allAtomicEntityList()) {
          if (atomicEntity instanceof Event) {
            Event event=(Event)atomicEntity;
            Actor[] refinements;
            try {
              refinements=event.getRefinement();
            }
 catch (            IllegalActionException e) {
              throw new InternalErrorException(e);
            }
            if (refinements != null) {
              for (              Actor refinement : refinements) {
                if (refinement == this) {
                  _executiveDirector=((ERGController)event.getContainer()).director;
                  break;
                }
              }
              if (_executiveDirector != null) {
                break;
              }
            }
          }
        }
      }
      _executiveDirectorVersion=workspace.getVersion();
    }
  }
  finally {
    workspace.doneReading();
  }
  return _executiveDirector;
}

Fixed version (ground truth):
/** 
 * Return the executive director. If the current controller is the top-level controller of an ERG modal model, then the executive director is its director (returned by   {@link #getDirector()}). Otherwise, the executive director is the director of the ERG controller at a higher level in the refinement hierarchy.
 * @return The executive director.
 */
public Director getExecutiveDirector(){
  Workspace workspace=workspace();
  try {
    workspace.getReadAccess();
    if (_executiveDirectorVersion != workspace.getVersion()) {
      NamedObj container=getContainer();
      if (!(container instanceof ERGModalModel)) {
        _executiveDirector=null;
        _executiveDirectorVersion=workspace.getVersion();
        return _executiveDirector;
      }
      ERGModalModel modalModel=(ERGModalModel)getContainer();
      if (modalModel.getController() == this) {
        _executiveDirector=super.getDirector();
      }
 else {
        _executiveDirector=null;
        for (        Object atomicEntity : modalModel.allAtomicEntityList()) {
          if (atomicEntity instanceof Event) {
            Event event=(Event)atomicEntity;
            Actor[] refinements;
            try {
              refinements=event.getRefinement();
            }
 catch (            IllegalActionException e) {
              throw new InternalErrorException(e);
            }
            if (refinements != null) {
              for (              Actor refinement : refinements) {
                if (refinement == this) {
                  _executiveDirector=((ERGController)event.getContainer()).director;
                  break;
                }
              }
              if (_executiveDirector != null) {
                break;
              }
            }
          }
        }
      }
      _executiveDirectorVersion=workspace.getVersion();
    }
  }
  finally {
    workspace.doneReading();
  }
  return _executiveDirector;
}