Program: 74926
Project: 74926
Buggy source:
/** 
 * Generate the type conversion initialize code. This method is called  by the Director to append necessary initialize code to handle type conversion.
 * @return The generated code.
 * @exception IllegalActionException Not thrown in this base class.
 */
public String generateTypeConvertInitializeCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  Iterator inputPorts=((Actor)_component).inputPortList().iterator();
  while (inputPorts.hasNext()) {
    TypedIOPort inputPort=(TypedIOPort)inputPorts.next();
    List sourcePorts=inputPort.sourcePortList();
    for (int i=0; i < sourcePorts.size(); i++) {
      TypedIOPort sourcePort=(TypedIOPort)sourcePorts.get(i);
      if (inputPort.getType().equals(sourcePort.getType())) {
        continue;
      }
      String sourcePortName=sourcePort.getName() + "String_Node_Str" + _getChannelIndex(inputPort,i,sourcePort);
      CodeGeneratorHelper sourceHelper=(CodeGeneratorHelper)_getHelper(sourcePort.getContainer());
      String type=(String)sourceHelper._portDeclareTypes.get(sourcePortName);
      String convert=(String)sourceHelper._portConversions.get(sourcePortName);
      if (type == null) {
      }
 else       if (type.equals("String_Node_Str")) {
        if (_isPrimitiveType(convert.substring(0,convert.indexOf("String_Node_Str")))) {
          for (int j=0; j < getBufferSize(inputPort,i); j++) {
            code.append("String_Node_Str" + _getReference(inputPort.getName() + "String_Node_Str" + i+ "String_Node_Str"+ j) + "String_Node_Str"+ convert+ "String_Node_Str");
          }
        }
      }
    }
  }
  return processCode(code.toString());
}

Fixed version (ground truth):
/** 
 * Generate the type conversion initialize code. This method is called  by the Director to append necessary initialize code to handle type conversion.
 * @return The generated code.
 * @exception IllegalActionException Not thrown in this base class.
 */
public String generateTypeConvertInitializeCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  Iterator inputPorts=((Actor)_component).inputPortList().iterator();
  while (inputPorts.hasNext()) {
    TypedIOPort inputPort=(TypedIOPort)inputPorts.next();
    List sourcePorts=inputPort.sourcePortList();
    for (int i=0; i < sourcePorts.size(); i++) {
      TypedIOPort sourcePort=(TypedIOPort)sourcePorts.get(i);
      if (inputPort.getType() == sourcePort.getType() || inputPort.getType() != BaseType.GENERAL) {
        continue;
      }
      String sourcePortName=sourcePort.getName() + "String_Node_Str" + _getChannelIndex(inputPort,i,sourcePort);
      CodeGeneratorHelper sourceHelper=(CodeGeneratorHelper)_getHelper(sourcePort.getContainer());
      String type=(String)sourceHelper._portDeclareTypes.get(sourcePortName);
      String convert=(String)sourceHelper._portConversions.get(sourcePortName);
      if (type == null) {
      }
 else       if (type.equals("String_Node_Str")) {
        if (_isPrimitiveType(convert.substring(0,convert.indexOf("String_Node_Str")))) {
          for (int j=0; j < getBufferSize(inputPort,i); j++) {
            code.append("String_Node_Str" + _getReference(inputPort.getName() + "String_Node_Str" + i+ "String_Node_Str"+ j) + "String_Node_Str"+ convert+ "String_Node_Str");
          }
        }
      }
    }
  }
  return processCode(code.toString());
}