Program: 74231
Project: 74231
Buggy source:
/** 
 * Generate the Moml string for the given object. If the object is a group of states, then the contents of the group are generated; otherwise, the Moml of the object itself is generated with   {@link NamedObj#exportMoML(String)}.
 * @param object The object.
 * @param name The name to be used for the object in the generated Moml.
 * @return The Moml string.
 */
public String getMoml(NamedObj object,String name){
  CompositeEntity group=(CompositeEntity)object;
  Attribute before=null;
  Attribute after=null;
  StringWriter buffer=new StringWriter();
  int extraIndent=0;
  try {
    buffer.write("String_Node_Str");
    before=object.getAttribute("String_Node_Str");
    if (before != null) {
      new Parameter(before,"String_Node_Str").setToken(BooleanToken.TRUE);
      buffer.write(StringUtilities.getIndentPrefix(1) + "String_Node_Str");
      before.exportMoML(buffer,2);
      buffer.write(StringUtilities.getIndentPrefix(1) + "String_Node_Str");
    }
    after=object.getAttribute("String_Node_Str");
    if (after != null) {
      new Parameter(after,"String_Node_Str").setToken(BooleanToken.TRUE);
    }
    if (after != null || before != null) {
      extraIndent++;
      buffer.write(StringUtilities.getIndentPrefix(extraIndent) + "String_Node_Str");
    }
    List<Attribute> attributes=group.attributeList();
    for (    Attribute attribute : attributes) {
      if (!_IGNORED_ATTRIBUTES.contains(attribute.getName()) && (after == null || attribute != after) && (before == null || attribute != before)) {
        attribute.exportMoML(buffer,extraIndent + 1);
      }
    }
    List<Port> ports=group.portList();
    for (    Port port : ports) {
      buffer.write(StringUtilities.getIndentPrefix(extraIndent + 1) + "String_Node_Str" + port.getName()+ "String_Node_Str");
      if (port instanceof IOPort) {
        IOPort ioPort=(IOPort)port;
        boolean isInput=ioPort.isInput();
        boolean isOutput=ioPort.isOutput();
        if (isInput) {
          buffer.write(StringUtilities.getIndentPrefix(extraIndent + 2) + "String_Node_Str");
        }
        if (isOutput) {
          buffer.write(StringUtilities.getIndentPrefix(extraIndent + 2) + "String_Node_Str");
        }
        if (ioPort.isMultiport()) {
          buffer.write(StringUtilities.getIndentPrefix(extraIndent + 2) + "String_Node_Str");
        }
      }
      attributes=port.attributeList();
      for (      Attribute attribute : attributes) {
        if (!_IGNORED_ATTRIBUTES.contains(attribute.getName())) {
          attribute.exportMoML(buffer,extraIndent + 2);
        }
      }
      buffer.write(StringUtilities.getIndentPrefix(extraIndent + 1) + "String_Node_Str");
    }
    buffer.write(StringUtilities.getIndentPrefix(extraIndent + 1) + "String_Node_Str");
    List<ComponentEntity> classes=group.classDefinitionList();
    for (    ComponentEntity entity : classes) {
      entity.exportMoML(buffer,extraIndent + 2);
    }
    List<ComponentEntity> entities=group.entityList();
    for (    ComponentEntity entity : entities) {
      entity.exportMoML(buffer,extraIndent + 2);
    }
    List<ComponentRelation> relations=group.relationList();
    for (    ComponentRelation relation : relations) {
      relation.exportMoML(buffer,extraIndent + 2);
    }
    buffer.write(group.exportLinks(extraIndent + 2,null));
    buffer.write(StringUtilities.getIndentPrefix(extraIndent + 1) + "String_Node_Str");
    if (after != null || before != null) {
      buffer.write(StringUtilities.getIndentPrefix(extraIndent) + "String_Node_Str");
    }
    if (after != null) {
      buffer.write(StringUtilities.getIndentPrefix(1) + "String_Node_Str");
      after.exportMoML(buffer,2);
      buffer.write(StringUtilities.getIndentPrefix(1) + "String_Node_Str");
    }
    buffer.write("String_Node_Str");
    return buffer.toString();
  }
 catch (  Exception e) {
    throw new InternalErrorException(null,e,"String_Node_Str" + "String_Node_Str" + group.getName() + "String_Node_Str");
  }
 finally {
    if (before != null) {
      Attribute attribute=before.getAttribute("String_Node_Str");
      if (attribute != null) {
        try {
          attribute.setContainer(null);
        }
 catch (        Throwable t) {
        }
      }
    }
    if (after != null) {
      Attribute attribute=after.getAttribute("String_Node_Str");
      if (attribute != null) {
        try {
          attribute.setContainer(null);
        }
 catch (        Throwable t) {
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Generate the Moml string for the given object. If the object is a group of states, then the contents of the group are generated; otherwise, the Moml of the object itself is generated with   {@link NamedObj#exportMoML(String)}.
 * @param object The object.
 * @param name The name to be used for the object in the generated Moml.
 * @return The Moml string.
 */
public String getMoml(NamedObj object,String name){
  CompositeEntity group=(CompositeEntity)object;
  Attribute before=object.getAttribute("String_Node_Str");
  Attribute after=object.getAttribute("String_Node_Str");
  StringWriter buffer=new StringWriter();
  int extraIndent=0;
  try {
    buffer.write("String_Node_Str");
    if (before != null) {
      String oldType=null;
      StringParameter typeParameter=(StringParameter)before.getAttribute("String_Node_Str");
      if (typeParameter == null) {
        typeParameter=new StringParameter(before,"String_Node_Str");
      }
 else {
        oldType=typeParameter.getExpression();
      }
      typeParameter.setExpression("String_Node_Str");
      try {
        buffer.write(StringUtilities.getIndentPrefix(1) + "String_Node_Str");
        before.exportMoML(buffer,2);
        buffer.write(StringUtilities.getIndentPrefix(1) + "String_Node_Str");
      }
  finally {
        if (oldType == null) {
          typeParameter.setContainer(null);
        }
 else {
          typeParameter.setExpression(oldType);
        }
      }
    }
    if (after != null || before != null) {
      extraIndent++;
      buffer.write(StringUtilities.getIndentPrefix(extraIndent) + "String_Node_Str");
    }
    List<Attribute> attributes=group.attributeList();
    for (    Attribute attribute : attributes) {
      if (!_IGNORED_ATTRIBUTES.contains(attribute.getName()) && (after == null || attribute != after) && (before == null || attribute != before)) {
        attribute.exportMoML(buffer,extraIndent + 1);
      }
    }
    List<Port> ports=group.portList();
    for (    Port port : ports) {
      buffer.write(StringUtilities.getIndentPrefix(extraIndent + 1) + "String_Node_Str" + port.getName()+ "String_Node_Str");
      if (port instanceof IOPort) {
        IOPort ioPort=(IOPort)port;
        boolean isInput=ioPort.isInput();
        boolean isOutput=ioPort.isOutput();
        if (isInput) {
          buffer.write(StringUtilities.getIndentPrefix(extraIndent + 2) + "String_Node_Str");
        }
        if (isOutput) {
          buffer.write(StringUtilities.getIndentPrefix(extraIndent + 2) + "String_Node_Str");
        }
        if (ioPort.isMultiport()) {
          buffer.write(StringUtilities.getIndentPrefix(extraIndent + 2) + "String_Node_Str");
        }
      }
      attributes=port.attributeList();
      for (      Attribute attribute : attributes) {
        if (!_IGNORED_ATTRIBUTES.contains(attribute.getName())) {
          attribute.exportMoML(buffer,extraIndent + 2);
        }
      }
      buffer.write(StringUtilities.getIndentPrefix(extraIndent + 1) + "String_Node_Str");
    }
    buffer.write(StringUtilities.getIndentPrefix(extraIndent + 1) + "String_Node_Str");
    List<ComponentEntity> classes=group.classDefinitionList();
    for (    ComponentEntity entity : classes) {
      entity.exportMoML(buffer,extraIndent + 2);
    }
    List<ComponentEntity> entities=group.entityList();
    for (    ComponentEntity entity : entities) {
      entity.exportMoML(buffer,extraIndent + 2);
    }
    List<ComponentRelation> relations=group.relationList();
    for (    ComponentRelation relation : relations) {
      relation.exportMoML(buffer,extraIndent + 2);
    }
    buffer.write(group.exportLinks(extraIndent + 2,null));
    buffer.write(StringUtilities.getIndentPrefix(extraIndent + 1) + "String_Node_Str");
    if (after != null || before != null) {
      buffer.write(StringUtilities.getIndentPrefix(extraIndent) + "String_Node_Str");
    }
    if (after != null) {
      String oldType=null;
      StringParameter typeParameter=(StringParameter)after.getAttribute("String_Node_Str");
      if (typeParameter == null) {
        typeParameter=new StringParameter(after,"String_Node_Str");
      }
 else {
        oldType=typeParameter.getExpression();
      }
      typeParameter.setExpression("String_Node_Str");
      try {
        buffer.write(StringUtilities.getIndentPrefix(1) + "String_Node_Str");
        after.exportMoML(buffer,2);
        buffer.write(StringUtilities.getIndentPrefix(1) + "String_Node_Str");
      }
  finally {
        if (oldType == null) {
          typeParameter.setContainer(null);
        }
 else {
          typeParameter.setExpression(oldType);
        }
      }
    }
    buffer.write("String_Node_Str");
    return buffer.toString();
  }
 catch (  Exception e) {
    throw new InternalErrorException(null,e,"String_Node_Str" + "String_Node_Str" + group.getName() + "String_Node_Str");
  }
}