Program: 75778
Project: 75778
Buggy source:
/** 
 * Return true if the receiver containing this boundary detector is connected to a boundary port. A boundary port is an opaque port that is contained by a composite actor. If the containing receiver is connected to a boundary port, then return true; otherwise return false. This method is not synchronized so the caller should be.
 * @return True if the containing receiver is connected toboundary port; return false otherwise.
 */
public boolean isConnectedToBoundary(){
  if (_connectedBoundaryCacheIsOn) {
    return _isConnectedBoundaryValue;
  }
 else {
    IOPort contPort=(IOPort)_rcvr.getContainer();
    if (contPort == null) {
      _connectedBoundaryCacheIsOn=false;
      _isConnectedBoundaryValue=false;
      return _isConnectedBoundaryValue;
    }
    ComponentEntity contEntity=(ComponentEntity)contPort.getContainer();
    IOPort connectedPort=null;
    ComponentEntity connectedEntity=null;
    Iterator ports=contPort.connectedPortList().iterator();
    int cnt=0;
    while (ports.hasNext()) {
      connectedPort=(IOPort)ports.next();
      connectedEntity=(ComponentEntity)connectedPort.getContainer();
      if (connectedEntity == contEntity.getContainer() && connectedPort.isInput()) {
        try {
          Receiver[][] rcvrs=connectedPort.deepGetReceivers();
          for (int i=0; i < rcvrs.length; i++) {
            for (int j=0; j < rcvrs[i].length; j++) {
              if (_rcvr == rcvrs[i][j]) {
                _connectedBoundaryCacheIsOn=true;
                _isConnectedBoundaryValue=true;
                return true;
              }
            }
          }
        }
 catch (        IllegalActionException e) {
          System.out.println("String_Node_Str" + "String_Node_Str");
        }
      }
 else       if (connectedPort.isOpaque() && !connectedEntity.isAtomic() && connectedPort.isOutput()) {
        Receiver[][] rcvrs=connectedPort.getRemoteReceivers();
        for (int i=0; i < rcvrs.length; i++) {
          for (int j=0; j < rcvrs[i].length; j++) {
            if (_rcvr == rcvrs[i][j]) {
              _connectedBoundaryCacheIsOn=true;
              _isConnectedBoundaryValue=true;
              return true;
            }
          }
        }
      }
    }
    _connectedBoundaryCacheIsOn=true;
    _isConnectedBoundaryValue=false;
    return _isConnectedBoundaryValue;
  }
}

Fixed version (ground truth):
/** 
 * Return true if the receiver containing this boundary detector is connected to a boundary port. A boundary port is an opaque port that is contained by a composite actor. If the containing receiver is connected to a boundary port, then return true; otherwise return false. This method is not synchronized so the caller should be.
 * @return True if the containing receiver is connected toboundary port; return false otherwise.
 */
public boolean isConnectedToBoundary(){
  if (_connectedBoundaryCacheIsOn) {
    return _isConnectedBoundaryValue;
  }
 else {
    IOPort contPort=(IOPort)_receiver.getContainer();
    if (contPort == null) {
      _connectedBoundaryCacheIsOn=false;
      _isConnectedBoundaryValue=false;
      return _isConnectedBoundaryValue;
    }
    ComponentEntity contEntity=(ComponentEntity)contPort.getContainer();
    IOPort connectedPort=null;
    ComponentEntity connectedEntity=null;
    Iterator ports=contPort.connectedPortList().iterator();
    while (ports.hasNext()) {
      connectedPort=(IOPort)ports.next();
      connectedEntity=(ComponentEntity)connectedPort.getContainer();
      if (connectedEntity == contEntity.getContainer() && connectedPort.isInput()) {
        try {
          Receiver[][] receivers=connectedPort.deepGetReceivers();
          for (int i=0; i < receivers.length; i++) {
            for (int j=0; j < receivers[i].length; j++) {
              if (_receiver == receivers[i][j]) {
                _connectedBoundaryCacheIsOn=true;
                _isConnectedBoundaryValue=true;
                return true;
              }
            }
          }
        }
 catch (        IllegalActionException e) {
          System.out.println("String_Node_Str" + "String_Node_Str");
        }
      }
 else       if (connectedPort.isOpaque() && !connectedEntity.isAtomic() && connectedPort.isOutput()) {
        Receiver[][] receivers=connectedPort.getRemoteReceivers();
        for (int i=0; i < receivers.length; i++) {
          for (int j=0; j < receivers[i].length; j++) {
            if (_receiver == receivers[i][j]) {
              _connectedBoundaryCacheIsOn=true;
              _isConnectedBoundaryValue=true;
              return true;
            }
          }
        }
      }
    }
    _connectedBoundaryCacheIsOn=true;
    _isConnectedBoundaryValue=false;
    return _isConnectedBoundaryValue;
  }
}