Program: 75795
Project: 75795
Buggy source:
/** 
 * If the argument is true, make the port an output port. If the argument is false, make the port not an output port. In addition, if the container is an instance of Refinement, and the argument is true, find the corresponding port of the controller and make it an input and not an output.  This makes it possible for the controller to see the outputs of the refinements. This method overrides the base class to make the same change on the mirror ports in the controller and state refinments. This method invalidates the schedule and resolved types of the director of the container, if there is one. It is write-synchronized on the workspace, and increments the version of the workspace.
 * @param isOutput True to make the port an output.
 */
public void setOutput(boolean isOutput){
  boolean disableStatus=_mirrorDisable;
  try {
    _workspace.getWriteAccess();
    if (_mirrorDisable || getContainer() == null) {
      super.setOutput(isOutput);
    }
 else {
      _mirrorDisable=true;
      boolean success=false;
      Nameable container=getContainer();
      if (container != null) {
        Nameable modal=container.getContainer();
        if (modal instanceof ModalModel) {
          Port port=((ModalModel)modal).getPort(getName());
          if (port instanceof IOPort) {
            ((IOPort)port).setOutput(isOutput);
            success=true;
          }
          if (isOutput && container instanceof Refinement) {
            ModalController controller=(ModalController)((ModalModel)modal).getEntity("String_Node_Str");
            if (controller != null) {
              RefinementPort controlPort=(RefinementPort)controller.getPort(getName());
              if (controlPort != null) {
                boolean controlPortStatus=controlPort._mirrorDisable;
                try {
                  controlPort._mirrorDisable=true;
                  controlPort.setInput(true);
                }
  finally {
                  controlPort._mirrorDisable=controlPortStatus;
                }
              }
            }
          }
        }
      }
      if (!success)       super.setOutput(isOutput);
    }
  }
  finally {
    _mirrorDisable=disableStatus;
    _workspace.doneWriting();
  }
}

Fixed version (ground truth):
/** 
 * If the argument is true, make the port an output port. If the argument is false, make the port not an output port. In addition, if the container is an instance of Refinement, and the argument is true, find the corresponding port of the controller and make it an input and not an output.  This makes it possible for the controller to see the outputs of the refinements. This method overrides the base class to make the same change on the mirror ports in the controller and state refinments. This method invalidates the schedule and resolved types of the director of the container, if there is one. It is write-synchronized on the workspace, and increments the version of the workspace.
 * @param isOutput True to make the port an output.
 */
public void setOutput(boolean isOutput){
  boolean disableStatus=_mirrorDisable;
  try {
    _workspace.getWriteAccess();
    if (_mirrorDisable || getContainer() == null) {
      super.setOutput(isOutput);
    }
 else {
      _mirrorDisable=true;
      boolean success=false;
      Nameable container=getContainer();
      if (container != null) {
        Nameable modal=container.getContainer();
        if (modal instanceof ModalModel) {
          Port port=((ModalModel)modal).getPort(getName());
          if (port instanceof IOPort) {
            ((IOPort)port).setOutput(isOutput);
            success=true;
          }
        }
      }
      if (!success)       super.setOutput(isOutput);
    }
  }
  finally {
    _mirrorDisable=disableStatus;
    _workspace.doneWriting();
  }
}