Program: 74803
Project: 74803
Buggy source:
/** 
 * Make all connections for this nested actor.
 * @param actor The actor for to connect to others.
 * @exception PtalonRuntimeException If thrown trying to access the parameter,or if unable to set the token for the corresponding paramter.
 */
public void makeConnections(ComponentEntity actor) throws PtalonRuntimeException {
  try {
    for (    String portName : _relations.keySet()) {
      String relationName=_actor.getMappedName(_relations.get(portName));
      TypedIORelation relation=(TypedIORelation)_actor.getRelation(relationName);
      TypedIOPort port=(TypedIOPort)actor.getPort(portName);
      if (port == null) {
        port=new TypedIOPort(actor,actor.uniqueName(portName));
        inner:         for (        Object connection : relation.linkedPortList()) {
          if (connection instanceof TypedIOPort) {
            TypedIOPort testPort=(TypedIOPort)connection;
            if (testPort.getContainer().equals(_actor)) {
              if (testPort.isInput()) {
                port.setInput(true);
              }
              if (testPort.isOutput()) {
                port.setOutput(true);
              }
            }
 else {
              if (testPort.isInput()) {
                port.setOutput(true);
              }
              if (testPort.isOutput()) {
                port.setInput(true);
              }
            }
            break inner;
          }
        }
      }
      port.link(relation);
    }
    for (    String portName : _transparencies.keySet()) {
      TypedIOPort port=(TypedIOPort)actor.getPort(portName);
      String shortName=_transparencies.get(portName);
      if (_transparentRelations.containsKey(shortName)) {
        TypedIOPort connectionPoint=_transparentRelations.get(shortName);
        String relationName=_actor.uniqueName("String_Node_Str");
        TypedIORelation rel=new TypedIORelation(_actor,relationName);
        if (port == null) {
          port=new TypedIOPort(actor,actor.uniqueName(portName));
          inner:           for (          Object connection : rel.linkedPortList()) {
            if (connection instanceof TypedIOPort) {
              TypedIOPort testPort=(TypedIOPort)connection;
              if (testPort.getContainer().equals(_actor)) {
                if (testPort.isInput()) {
                  port.setInput(true);
                }
                if (testPort.isOutput()) {
                  port.setOutput(true);
                }
              }
 else {
                if (testPort.isInput()) {
                  port.setOutput(true);
                }
                if (testPort.isOutput()) {
                  port.setInput(true);
                }
              }
              break inner;
            }
          }
        }
        port.link(rel);
        connectionPoint.link(rel);
      }
 else {
        if (port == null) {
          port=new TypedIOPort(actor,actor.uniqueName(portName));
          port.setMultiport(true);
          port.setInput(true);
          port.setOutput(false);
        }
        _transparentRelations.put(shortName,port);
      }
    }
    for (    String portName : _ports.keySet()) {
      TypedIOPort port=(TypedIOPort)actor.getPort(portName);
      String containerPortName=_actor.getMappedName(_ports.get(portName));
      TypedIOPort containerPort=(TypedIOPort)_actor.getPort(containerPortName);
      if (port == null) {
        port=new TypedIOPort(actor,actor.uniqueName(portName));
        if (containerPort.isInput()) {
          port.setInput(true);
        }
        if (containerPort.isOutput()) {
          port.setOutput(true);
        }
      }
      String relationName=_actor.uniqueName("String_Node_Str");
      TypedIORelation relation=new TypedIORelation(_actor,relationName);
      port.link(relation);
      containerPort.link(relation);
    }
    for (    String portName : _unknownPrefixes.keySet()) {
      String suffix=evaluateString(_unknownExpressions.get(portName));
      if (suffix == null) {
        throw new PtalonRuntimeException("String_Node_Str" + _unknownExpressions.get(portName));
      }
      String name=_unknownPrefixes.get(portName) + suffix;
      if (getType(name).endsWith("String_Node_Str")) {
        TypedIOPort port=(TypedIOPort)actor.getPort(portName);
        String containerPortName=_actor.getMappedName(name);
        TypedIOPort containerPort=(TypedIOPort)_actor.getPort(containerPortName);
        if (port == null) {
          port=new TypedIOPort(actor,actor.uniqueName(portName));
          if (containerPort.isInput()) {
            port.setInput(true);
          }
          if (containerPort.isOutput()) {
            port.setOutput(true);
          }
        }
        String relationName=_actor.uniqueName("String_Node_Str");
        TypedIORelation relation=new TypedIORelation(_actor,relationName);
        port.link(relation);
        containerPort.link(relation);
      }
 else       if (getType(name).equals("String_Node_Str")) {
        String relationName=_actor.getMappedName(name);
        TypedIORelation relation=(TypedIORelation)_actor.getRelation(relationName);
        TypedIOPort port=(TypedIOPort)actor.getPort(portName);
        if (port == null) {
          port=new TypedIOPort(actor,actor.uniqueName(portName));
          inner:           for (          Object connection : relation.linkedPortList()) {
            if (connection instanceof TypedIOPort) {
              TypedIOPort testPort=(TypedIOPort)connection;
              if (testPort.getContainer().equals(_actor)) {
                if (testPort.isInput()) {
                  port.setInput(true);
                }
                if (testPort.isOutput()) {
                  port.setOutput(true);
                }
              }
 else {
                if (testPort.isInput()) {
                  port.setOutput(true);
                }
                if (testPort.isOutput()) {
                  port.setInput(true);
                }
              }
              break inner;
            }
          }
        }
        port.link(relation);
      }
 else       if (getType(name).equals("String_Node_Str")) {
        TypedIOPort port=(TypedIOPort)actor.getPort(portName);
        if (_transparentRelations.containsKey(name)) {
          TypedIOPort connectionPoint=_transparentRelations.get(name);
          String relationName=_actor.uniqueName("String_Node_Str");
          TypedIORelation rel=new TypedIORelation(_actor,relationName);
          port.link(rel);
          if (port == null) {
            port=new TypedIOPort(actor,actor.uniqueName(portName));
            inner:             for (            Object connection : rel.linkedPortList()) {
              if (connection instanceof TypedIOPort) {
                TypedIOPort testPort=(TypedIOPort)connection;
                if (testPort.getContainer().equals(_actor)) {
                  if (testPort.isInput()) {
                    port.setInput(true);
                  }
                  if (testPort.isOutput()) {
                    port.setOutput(true);
                  }
                }
 else {
                  if (testPort.isInput()) {
                    port.setOutput(true);
                  }
                  if (testPort.isOutput()) {
                    port.setInput(true);
                  }
                }
                break inner;
              }
            }
          }
          connectionPoint.link(rel);
        }
 else {
          if (port == null) {
            port=new TypedIOPort(actor,actor.uniqueName(portName));
            port.setMultiport(true);
            port.setInput(true);
            port.setOutput(false);
          }
          _transparentRelations.put(name,port);
        }
      }
 else {
        throw new PtalonRuntimeException(name + "String_Node_Str");
      }
    }
    if (_danglingPortsOkay) {
      return;
    }
    PtalonActor container=(PtalonActor)actor.getContainer();
    for (    Object port : actor.portList()) {
      if (port instanceof TypedIOPort) {
        TypedIOPort ioport=(TypedIOPort)port;
        if (ioport.numLinks() == 0) {
          String name=container.uniqueName(actor.getName() + "String_Node_Str" + ioport.getName());
          TypedIOPort newPort=new TypedIOPort(container,name);
          String rel=container.uniqueName("String_Node_Str");
          TypedIORelation relation=new TypedIORelation(container,rel);
          if (ioport.isMultiport()) {
            relation.setWidth(ioport.getWidth());
            newPort.setMultiport(true);
            if (ioport.getWidth() == 0) {
              ioport.link(relation);
              newPort.link(relation);
            }
 else {
              int width=ioport.getWidth();
              while (width > 0) {
                ioport.link(relation);
                newPort.link(relation);
                width--;
              }
            }
          }
 else {
            ioport.link(relation);
            newPort.link(relation);
          }
        }
      }
    }
  }
 catch (  Exception e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Make all connections for this nested actor.
 * @param actor The actor for to connect to others.
 * @exception PtalonRuntimeException If thrown trying to access the parameter,or if unable to set the token for the corresponding paramter.
 */
public void makeConnections(ComponentEntity actor) throws PtalonRuntimeException {
  try {
    for (    String portName : _relations.keySet()) {
      String relationName=_actor.getMappedName(_relations.get(portName));
      TypedIORelation relation=(TypedIORelation)_actor.getRelation(relationName);
      TypedIOPort port=(TypedIOPort)actor.getPort(portName);
      if (port == null) {
        port=new TypedIOPort(actor,actor.uniqueName(portName));
        inner:         for (        Object connection : relation.linkedPortList()) {
          if (connection instanceof TypedIOPort) {
            TypedIOPort testPort=(TypedIOPort)connection;
            if (testPort.getContainer().equals(_actor)) {
              if (testPort.isInput()) {
                port.setInput(true);
              }
              if (testPort.isOutput()) {
                port.setOutput(true);
              }
            }
 else {
              if (testPort.isInput()) {
                port.setOutput(true);
              }
              if (testPort.isOutput()) {
                port.setInput(true);
              }
            }
            break inner;
          }
        }
      }
      port.link(relation);
    }
    for (    String portName : _transparencies.keySet()) {
      TypedIOPort port=(TypedIOPort)actor.getPort(portName);
      String shortName=_transparencies.get(portName);
      if (_transparentRelations.containsKey(shortName)) {
        TypedIOPort connectionPoint=_transparentRelations.get(shortName);
        String relationName=_actor.uniqueName("String_Node_Str");
        TypedIORelation rel=new TypedIORelation(_actor,relationName);
        if (port == null) {
          port=new TypedIOPort(actor,actor.uniqueName(portName));
          inner:           for (          Object connection : rel.linkedPortList()) {
            if (connection instanceof TypedIOPort) {
              TypedIOPort testPort=(TypedIOPort)connection;
              if (testPort.getContainer().equals(_actor)) {
                if (testPort.isInput()) {
                  port.setInput(true);
                }
                if (testPort.isOutput()) {
                  port.setOutput(true);
                }
              }
 else {
                if (testPort.isInput()) {
                  port.setOutput(true);
                }
                if (testPort.isOutput()) {
                  port.setInput(true);
                }
              }
              break inner;
            }
          }
        }
        port.link(rel);
        connectionPoint.link(rel);
      }
 else {
        if (port == null) {
          port=new TypedIOPort(actor,actor.uniqueName(portName));
          port.setMultiport(true);
          port.setInput(true);
          port.setOutput(false);
        }
        _transparentRelations.put(shortName,port);
      }
    }
    for (    String portName : _ports.keySet()) {
      TypedIOPort port=(TypedIOPort)actor.getPort(portName);
      String containerPortName=_actor.getMappedName(_ports.get(portName));
      TypedIOPort containerPort=(TypedIOPort)_actor.getPort(containerPortName);
      if (port == null) {
        port=new TypedIOPort(actor,actor.uniqueName(portName));
        if (containerPort.isInput()) {
          port.setInput(true);
        }
        if (containerPort.isOutput()) {
          port.setOutput(true);
        }
      }
      String relationName=_actor.uniqueName("String_Node_Str");
      TypedIORelation relation=new TypedIORelation(_actor,relationName);
      port.link(relation);
      containerPort.link(relation);
    }
    for (    String portName : _unknownPrefixes.keySet()) {
      String suffix=evaluateString(_unknownExpressions.get(portName));
      if (suffix == null) {
        throw new PtalonRuntimeException("String_Node_Str" + _unknownExpressions.get(portName));
      }
      String name=_unknownPrefixes.get(portName) + suffix;
      if (_getType(name).endsWith("String_Node_Str")) {
        TypedIOPort port=(TypedIOPort)actor.getPort(portName);
        String containerPortName=_actor.getMappedName(name);
        TypedIOPort containerPort=(TypedIOPort)_actor.getPort(containerPortName);
        if (port == null) {
          port=new TypedIOPort(actor,actor.uniqueName(portName));
          if (containerPort.isInput()) {
            port.setInput(true);
          }
          if (containerPort.isOutput()) {
            port.setOutput(true);
          }
        }
        String relationName=_actor.uniqueName("String_Node_Str");
        TypedIORelation relation=new TypedIORelation(_actor,relationName);
        port.link(relation);
        containerPort.link(relation);
      }
 else       if (_getType(name).equals("String_Node_Str")) {
        String relationName=_actor.getMappedName(name);
        TypedIORelation relation=(TypedIORelation)_actor.getRelation(relationName);
        TypedIOPort port=(TypedIOPort)actor.getPort(portName);
        if (port == null) {
          port=new TypedIOPort(actor,actor.uniqueName(portName));
          inner:           for (          Object connection : relation.linkedPortList()) {
            if (connection instanceof TypedIOPort) {
              TypedIOPort testPort=(TypedIOPort)connection;
              if (testPort.getContainer().equals(_actor)) {
                if (testPort.isInput()) {
                  port.setInput(true);
                }
                if (testPort.isOutput()) {
                  port.setOutput(true);
                }
              }
 else {
                if (testPort.isInput()) {
                  port.setOutput(true);
                }
                if (testPort.isOutput()) {
                  port.setInput(true);
                }
              }
              break inner;
            }
          }
        }
        port.link(relation);
      }
 else       if (_getType(name).equals("String_Node_Str")) {
        TypedIOPort port=(TypedIOPort)actor.getPort(portName);
        if (_transparentRelations.containsKey(name)) {
          TypedIOPort connectionPoint=_transparentRelations.get(name);
          String relationName=_actor.uniqueName("String_Node_Str");
          TypedIORelation rel=new TypedIORelation(_actor,relationName);
          port.link(rel);
          if (port == null) {
            port=new TypedIOPort(actor,actor.uniqueName(portName));
            inner:             for (            Object connection : rel.linkedPortList()) {
              if (connection instanceof TypedIOPort) {
                TypedIOPort testPort=(TypedIOPort)connection;
                if (testPort.getContainer().equals(_actor)) {
                  if (testPort.isInput()) {
                    port.setInput(true);
                  }
                  if (testPort.isOutput()) {
                    port.setOutput(true);
                  }
                }
 else {
                  if (testPort.isInput()) {
                    port.setOutput(true);
                  }
                  if (testPort.isOutput()) {
                    port.setInput(true);
                  }
                }
                break inner;
              }
            }
          }
          connectionPoint.link(rel);
        }
 else {
          if (port == null) {
            port=new TypedIOPort(actor,actor.uniqueName(portName));
            port.setMultiport(true);
            port.setInput(true);
            port.setOutput(false);
          }
          _transparentRelations.put(name,port);
        }
      }
 else {
        throw new PtalonRuntimeException(name + "String_Node_Str");
      }
    }
    if (_danglingPortsOkay) {
      return;
    }
    PtalonActor container=(PtalonActor)actor.getContainer();
    for (    Object port : actor.portList()) {
      if (port instanceof TypedIOPort) {
        TypedIOPort ioport=(TypedIOPort)port;
        if (ioport.numLinks() == 0) {
          String name=container.uniqueName(actor.getName() + "String_Node_Str" + ioport.getName());
          TypedIOPort newPort=new TypedIOPort(container,name);
          String rel=container.uniqueName("String_Node_Str");
          TypedIORelation relation=new TypedIORelation(container,rel);
          if (ioport.isMultiport()) {
            relation.setWidth(ioport.getWidth());
            newPort.setMultiport(true);
            if (ioport.getWidth() == 0) {
              ioport.link(relation);
              newPort.link(relation);
            }
 else {
              int width=ioport.getWidth();
              while (width > 0) {
                ioport.link(relation);
                newPort.link(relation);
                width--;
              }
            }
          }
 else {
            ioport.link(relation);
            newPort.link(relation);
          }
        }
      }
    }
  }
 catch (  Exception e) {
    throw new PtalonRuntimeException("String_Node_Str",e);
  }
}