Program: 75207
Project: 75207
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. 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.
 * @exception IllegalActionException If changing the port status isnot permitted.
 */
public void setOutput(boolean isOutput) throws IllegalActionException {
  try {
    _workspace.getWriteAccess();
    super.setOutput(isOutput);
    ModalModel container=(ModalModel)getContainer();
    Iterator entities=container.entityList().iterator();
    while (entities.hasNext()) {
      Entity entity=(Entity)entities.next();
      Port mirrorPort=entity.getPort(getName());
      if (mirrorPort instanceof RefinementPort) {
        RefinementPort castPort=(RefinementPort)mirrorPort;
        boolean disableStatus=castPort._mirrorDisable;
        try {
          castPort._mirrorDisable=true;
          castPort.setOutput(isOutput);
        }
  finally {
          castPort._mirrorDisable=disableStatus;
        }
        if (entity.getName().equals("String_Node_Str")) {
          boolean controlPortStatus=castPort._mirrorDisable;
          try {
            castPort._mirrorDisable=true;
            castPort.setInput(true);
          }
  finally {
            castPort._mirrorDisable=controlPortStatus;
          }
        }
      }
    }
  }
  finally {
    _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. 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.
 * @exception IllegalActionException If changing the port status isnot permitted.
 */
public void setOutput(boolean isOutput) throws IllegalActionException {
  try {
    _workspace.getWriteAccess();
    super.setOutput(isOutput);
    ModalModel container=(ModalModel)getContainer();
    Iterator entities=container.entityList().iterator();
    while (entities.hasNext()) {
      Entity entity=(Entity)entities.next();
      Port mirrorPort=entity.getPort(getName());
      if (mirrorPort instanceof RefinementPort) {
        RefinementPort castPort=(RefinementPort)mirrorPort;
        boolean disableStatus=castPort._mirrorDisable;
        try {
          castPort._mirrorDisable=true;
          castPort.setOutput(isOutput);
        }
  finally {
          castPort._mirrorDisable=disableStatus;
        }
        if (entity.getName().equals("String_Node_Str")) {
          boolean controlPortStatus=castPort._mirrorDisable;
          try {
            castPort._mirrorDisable=true;
            castPort.setInput(true);
            if (!isInput()) {
              castPort._automaticallyInput=true;
            }
          }
  finally {
            castPort._mirrorDisable=controlPortStatus;
          }
        }
      }
    }
  }
  finally {
    _workspace.doneWriting();
  }
}