Program: 73880
Project: 73880
Buggy source:
/** 
 * Writing out the profile for the composite actor and print out the dot file.
 * @param container The composite actor whose profile to be generated.
 * @param actorFirings 
 * @param firingClusters
 * @param esdf
 * @throws IllegalActionException
 */
private void _generateProfile(CompositeActor container,List actorFirings,List<FiringCluster> firingClusters,StringBuffer esdf) throws IllegalActionException {
  esdf.append(INDENT1 + "String_Node_Str" + _eol);
  esdf.append(INDENT2 + "String_Node_Str" + _eol);
  esdf.append(INDENT2 + "String_Node_Str" + _eol+ _eol);
  for (  FiringCluster cluster : firingClusters) {
    int index=firingClusters.indexOf(cluster);
    esdf.append(INDENT2 + "String_Node_Str" + index+ "String_Node_Str"+ _eol);
    String externalPortName;
    for (    IOPort inputPort : cluster.inputPorts) {
      externalPortName="String_Node_Str";
      for (      Object connectedPort : inputPort.connectedPortList()) {
        if (container.portList().contains(connectedPort)) {
          externalPortName=((IOPort)connectedPort).getName();
          break;
        }
      }
      if (!externalPortName.equals("String_Node_Str")) {
        esdf.append(INDENT2 + "String_Node_Str" + inputPort.getName()+ "String_Node_Str"+ externalPortName+ "String_Node_Str"+ DFUtilities.getTokenConsumptionRate(inputPort)+ "String_Node_Str"+ inputPort.isInput()+ "String_Node_Str"+ _eol);
      }
    }
    for (    IOPort outputPort : cluster.outputPorts) {
      externalPortName="String_Node_Str";
      for (      Object connectedPort : outputPort.connectedPortList()) {
        if (container.portList().contains(connectedPort)) {
          externalPortName=((IOPort)connectedPort).getName();
          break;
        }
      }
      if (!externalPortName.equals("String_Node_Str"))       esdf.append(INDENT2 + "String_Node_Str" + outputPort.getName()+ "String_Node_Str"+ externalPortName+ "String_Node_Str"+ DFUtilities.getTokenProductionRate(outputPort)+ "String_Node_Str"+ outputPort.isInput()+ "String_Node_Str"+ _eol);
    }
    for (    FiringCluster nextCluster : cluster.nextClusters) {
      esdf.append(INDENT2 + "String_Node_Str" + firingClusters.indexOf(nextCluster)+ "String_Node_Str"+ _eol);
    }
    for (    FiringCluster previousCluster : cluster.previousClusters) {
      esdf.append(INDENT2 + "String_Node_Str" + firingClusters.indexOf(previousCluster)+ "String_Node_Str"+ _eol);
    }
    for (    FiringCluster nextCluster : cluster.nextIterationClusters) {
      esdf.append(INDENT2 + "String_Node_Str" + firingClusters.indexOf(nextCluster)+ "String_Node_Str"+ _eol);
    }
    for (    FiringCluster previousCluster : cluster.previousIterationClusters) {
      esdf.append(INDENT2 + "String_Node_Str" + firingClusters.indexOf(previousCluster)+ "String_Node_Str"+ _eol);
    }
    esdf.append(INDENT2 + "String_Node_Str" + _eol+ _eol);
  }
  StringBuffer graph=new StringBuffer();
  System.out.println("String_Node_Str" + actorFirings.size());
  graph.append("String_Node_Str" + _eol + "String_Node_Str"+ _eol+ "String_Node_Str"+ _eol);
  for (Iterator firings=actorFirings.iterator(); firings.hasNext(); ) {
    Firing firing=(Firing)firings.next();
    for (Iterator nextFirings=firing.nextActorFirings.iterator(); nextFirings.hasNext(); ) {
      Firing nextFiring=(Firing)nextFirings.next();
      graph.append("String_Node_Str" + firing.actor.getName() + "String_Node_Str"+ firing.firingIndex+ "String_Node_Str"+ firing.firingFunction+ "String_Node_Str"+ nextFiring.actor.getName()+ "String_Node_Str"+ nextFiring.firingIndex+ "String_Node_Str"+ nextFiring.firingFunction+ "String_Node_Str"+ _eol);
    }
  }
  for (  FiringCluster cluster : firingClusters) {
    graph.append("String_Node_Str" + "String_Node_Str" + firingClusters.indexOf(cluster) + "String_Node_Str"+ _eol+ "String_Node_Str"+ firingClusters.indexOf(cluster)+ "String_Node_Str"+ _eol);
    for (    Firing firing : cluster.actorFirings) {
      graph.append("String_Node_Str" + firing.actor.getName() + "String_Node_Str"+ firing.firingIndex+ "String_Node_Str"+ firing.firingFunction+ "String_Node_Str"+ _eol);
    }
    graph.append("String_Node_Str" + _eol);
  }
  StringBuffer clustersGraph=new StringBuffer();
  clustersGraph.append("String_Node_Str" + _eol + "String_Node_Str"+ _eol);
  for (  FiringCluster cluster : firingClusters) {
    int index=firingClusters.indexOf(cluster);
    for (    FiringCluster nextCluster : cluster.nextClusters) {
      clustersGraph.append("String_Node_Str" + "String_Node_Str" + index + "String_Node_Str"+ "String_Node_Str"+ firingClusters.indexOf(nextCluster)+ "String_Node_Str"+ _eol);
    }
    for (    FiringCluster nextCluster : cluster.nextIterationClusters) {
      clustersGraph.append("String_Node_Str" + "String_Node_Str" + index + "String_Node_Str"+ "String_Node_Str"+ firingClusters.indexOf(nextCluster)+ "String_Node_Str"+ _eol);
    }
  }
  graph.append("String_Node_Str" + _eol);
  clustersGraph.append("String_Node_Str");
  String modelName=NamedProgramCodeGeneratorAdapter.generateName(_model);
  _writeCodeFileName(graph,modelName + "String_Node_Str",true,true);
  _writeCodeFileName(clustersGraph,modelName + "String_Node_Str",true,true);
  esdf.append(INDENT2 + "String_Node_Str" + _eol);
  esdf.append(INDENT1 + "String_Node_Str" + _eol);
}

Fixed version (ground truth):
/** 
 * Writing out the profile for the composite actor and print out the dot file.
 * @param container The composite actor whose profile to be generated.
 * @param actorFirings 
 * @param firingClusters
 * @param esdf
 * @throws IllegalActionException
 */
private void _generateProfile(CompositeActor container,List actorFirings,List<FiringCluster> firingClusters,StringBuffer esdf) throws IllegalActionException {
  esdf.append(INDENT1 + "String_Node_Str" + _eol);
  esdf.append(INDENT2 + "String_Node_Str" + _eol);
  esdf.append(INDENT2 + "String_Node_Str" + _eol+ _eol);
  for (  FiringCluster cluster : firingClusters) {
    int index=firingClusters.indexOf(cluster);
    esdf.append(INDENT2 + "String_Node_Str" + index+ "String_Node_Str"+ _eol);
    String externalPortName;
    for (    IOPort inputPort : cluster.inputPorts) {
      externalPortName="String_Node_Str";
      for (      Object connectedPort : inputPort.connectedPortList()) {
        if (container.portList().contains(connectedPort)) {
          externalPortName=((IOPort)connectedPort).getName();
          break;
        }
      }
      if (!externalPortName.equals("String_Node_Str")) {
        esdf.append(INDENT2 + "String_Node_Str" + inputPort.getName()+ "String_Node_Str"+ externalPortName+ "String_Node_Str"+ DFUtilities.getTokenConsumptionRate(inputPort)+ "String_Node_Str"+ inputPort.isInput()+ "String_Node_Str"+ _eol);
      }
    }
    for (    IOPort outputPort : cluster.outputPorts) {
      externalPortName="String_Node_Str";
      for (      Object connectedPort : outputPort.connectedPortList()) {
        if (container.portList().contains(connectedPort)) {
          externalPortName=((IOPort)connectedPort).getName();
          break;
        }
      }
      if (!externalPortName.equals("String_Node_Str"))       esdf.append(INDENT2 + "String_Node_Str" + outputPort.getName()+ "String_Node_Str"+ externalPortName+ "String_Node_Str"+ DFUtilities.getTokenProductionRate(outputPort)+ "String_Node_Str"+ outputPort.isInput()+ "String_Node_Str"+ _eol);
    }
    for (    FiringCluster nextCluster : cluster.nextClusters) {
      esdf.append(INDENT2 + "String_Node_Str" + firingClusters.indexOf(nextCluster)+ "String_Node_Str"+ _eol);
    }
    for (    FiringCluster previousCluster : cluster.previousClusters) {
      esdf.append(INDENT2 + "String_Node_Str" + firingClusters.indexOf(previousCluster)+ "String_Node_Str"+ _eol);
    }
    for (    FiringCluster nextCluster : cluster.nextIterationClusters) {
      esdf.append(INDENT2 + "String_Node_Str" + firingClusters.indexOf(nextCluster)+ "String_Node_Str"+ _eol);
    }
    for (    FiringCluster previousCluster : cluster.previousIterationClusters) {
      esdf.append(INDENT2 + "String_Node_Str" + firingClusters.indexOf(previousCluster)+ "String_Node_Str"+ _eol);
    }
    esdf.append(INDENT2 + "String_Node_Str" + _eol+ _eol);
  }
  StringBuffer graph=new StringBuffer();
  System.out.println("String_Node_Str" + actorFirings.size());
  graph.append("String_Node_Str" + _eol + "String_Node_Str"+ _eol+ "String_Node_Str"+ _eol);
  for (Iterator firings=actorFirings.iterator(); firings.hasNext(); ) {
    Firing firing=(Firing)firings.next();
    graph.append("String_Node_Str" + firing.actor.getName() + "String_Node_Str"+ firing.firingIndex+ "String_Node_Str"+ firing.firingFunction+ "String_Node_Str"+ _eol);
    for (Iterator nextFirings=firing.nextActorFirings.iterator(); nextFirings.hasNext(); ) {
      Firing nextFiring=(Firing)nextFirings.next();
      graph.append("String_Node_Str" + firing.actor.getName() + "String_Node_Str"+ firing.firingIndex+ "String_Node_Str"+ firing.firingFunction+ "String_Node_Str"+ nextFiring.actor.getName()+ "String_Node_Str"+ nextFiring.firingIndex+ "String_Node_Str"+ nextFiring.firingFunction+ "String_Node_Str"+ _eol);
    }
  }
  for (  FiringCluster cluster : firingClusters) {
    graph.append("String_Node_Str" + "String_Node_Str" + firingClusters.indexOf(cluster) + "String_Node_Str"+ _eol+ "String_Node_Str"+ firingClusters.indexOf(cluster)+ "String_Node_Str"+ _eol);
    for (    Firing firing : cluster.actorFirings) {
      graph.append("String_Node_Str" + firing.actor.getName() + "String_Node_Str"+ firing.firingIndex+ "String_Node_Str"+ firing.firingFunction+ "String_Node_Str"+ _eol);
    }
    graph.append("String_Node_Str" + _eol);
  }
  StringBuffer clustersGraph=new StringBuffer();
  clustersGraph.append("String_Node_Str" + _eol + "String_Node_Str"+ _eol);
  for (  FiringCluster cluster : firingClusters) {
    int index=firingClusters.indexOf(cluster);
    clustersGraph.append("String_Node_Str" + "String_Node_Str" + index + "String_Node_Str"+ _eol);
    for (    FiringCluster nextCluster : cluster.nextClusters) {
      clustersGraph.append("String_Node_Str" + "String_Node_Str" + index + "String_Node_Str"+ "String_Node_Str"+ firingClusters.indexOf(nextCluster)+ "String_Node_Str"+ _eol);
    }
    for (    FiringCluster nextCluster : cluster.nextIterationClusters) {
      clustersGraph.append("String_Node_Str" + "String_Node_Str" + index + "String_Node_Str"+ "String_Node_Str"+ firingClusters.indexOf(nextCluster)+ "String_Node_Str"+ _eol);
    }
  }
  graph.append("String_Node_Str" + _eol);
  clustersGraph.append("String_Node_Str");
  String modelName=NamedProgramCodeGeneratorAdapter.generateName(_model);
  _writeCodeFileName(graph,modelName + "String_Node_Str",true,true);
  _writeCodeFileName(clustersGraph,modelName + "String_Node_Str",true,true);
  esdf.append(INDENT2 + "String_Node_Str" + _eol);
  esdf.append(INDENT1 + "String_Node_Str" + _eol);
}