Program: 21640
Project: 21640
Buggy source:
public static Element exportObject(OTDataObject dataObj,OTDataObject parent,String parentResourceName) throws Exception {
  OTID id=dataObj.getGlobalId();
  if (writtenIds.contains(id)) {
    return exportObjectReference(id);
  }
  XMLDataObject xmlDO=null;
  if (dataObj instanceof XMLDataObject) {
    xmlDO=(XMLDataObject)dataObj;
    XMLDataObject container=xmlDO.getContainer();
    if (container != null && processedIds.contains(container.getGlobalId())) {
      if (parent != container || !parentResourceName.equals(xmlDO.getContainerResourceKey())) {
        return exportObjectReference(id);
      }
    }
  }
  writtenIds.add(id);
  String objectFullClassName=OTrunkImpl.getClassName(dataObj);
  String objectElementName=getObjectElementName(objectFullClassName);
  Element objectEl=new Element(objectElementName);
  if (xmlDO != null && xmlDO.getLocalId() != null) {
    objectEl.setAttribute("String_Node_Str",xmlDO.getLocalId());
  }
 else {
    ArrayList incomingReferences=(ArrayList)incomingReferenceMap.get(id);
    if (incomingReferences != null && incomingReferences.size() > 1) {
      objectEl.setAttribute("String_Node_Str",id.toString());
    }
  }
  String resourceKeys[]=dataObj.getResourceKeys();
  for (int i=0; i < resourceKeys.length; i++) {
    String resourceName=resourceKeys[i];
    if (resourceName.equals("String_Node_Str") || resourceName.equals("String_Node_Str")) {
      continue;
    }
    Object resource=dataObj.getResource(resourceName);
    if (resource instanceof OTID) {
      Element objectIDEl=exportID(dataObj,(OTID)resource,resourceName);
      writeResourceElement(dataObj,objectEl,resourceName,objectIDEl);
    }
 else     if (resource instanceof OTDataList) {
      OTDataList list=(OTDataList)resource;
      if (list.size() == 0) {
        continue;
      }
      ArrayList content=new ArrayList();
      for (int j=0; j < list.size(); j++) {
        Object listElement=list.get(j);
        if (listElement == null) {
          System.err.println("String_Node_Str");
          continue;
        }
        if (list instanceof XMLDataList) {
          XMLReferenceInfo info=((XMLDataList)list).getReferenceInfo(j);
          if (info != null && info.comment != null) {
            content.add(new Comment(info.comment));
          }
        }
        Element collectionEl=exportCollectionItem(dataObj,listElement,resourceName);
        if (collectionEl != null) {
          content.add(collectionEl);
        }
      }
      writeResourceElement(dataObj,objectEl,resourceName,content);
    }
 else     if (resource instanceof OTDataMap) {
      OTDataMap map=(OTDataMap)resource;
      String[] mapKeys=map.getKeys();
      ArrayList content=new ArrayList();
      for (int j=0; j < mapKeys.length; j++) {
        Element entryEl=new Element("String_Node_Str");
        content.add(content);
        entryEl.setAttribute("String_Node_Str",mapKeys[j]);
        Object mapValue=map.get(mapKeys[j]);
        if (mapValue != null) {
          Element collectionEl=exportCollectionItem(dataObj,mapValue,resourceName);
          entryEl.addContent(collectionEl);
        }
      }
      writeResourceElement(dataObj,objectEl,resourceName,content);
    }
 else     if (resource instanceof BlobResource) {
      BlobResource blob=(BlobResource)resource;
      Object blobUrl=blob.getBlobURL();
      String blobString=null;
      int defaultType=XMLReferenceInfo.ELEMENT;
      if (blobUrl != null) {
        blobString=blobUrl.toString();
        defaultType=XMLReferenceInfo.ATTRIBUTE;
      }
 else {
        blobString=BlobTypeHandler.base64(blob.getBytes());
      }
      writeResource(dataObj,objectEl,resourceName,blobString,defaultType);
    }
 else     if (resource == null) {
      System.err.println("String_Node_Str");
    }
 else     if (resource instanceof Integer || resource instanceof Float || resource instanceof Byte|| resource instanceof Short|| resource instanceof Boolean) {
      String primitiveString=resource.toString();
      writeResource(dataObj,objectEl,resourceName,primitiveString,XMLReferenceInfo.ATTRIBUTE);
    }
 else     if (resource instanceof OTXMLString) {
      SAXBuilder builder=new SAXBuilder();
      String xmlString="String_Node_Str" + ((OTXMLString)resource).getContent().trim() + "String_Node_Str";
      StringReader reader=new StringReader(xmlString);
      try {
        Document xmlStringDoc=builder.build(reader,resourceName);
        Element rootXMLStringEl=xmlStringDoc.getRootElement();
        writeResourceElement(dataObj,objectEl,resourceName,rootXMLStringEl.cloneContent());
      }
 catch (      JDOMParseException e) {
        System.err.println("String_Node_Str");
        System.err.println("String_Node_Str");
        System.err.println(xmlString);
        System.err.println("String_Node_Str");
        e.printStackTrace();
      }
    }
 else {
      String primitiveString=resource.toString();
      writeResource(dataObj,objectEl,resourceName,primitiveString,XMLReferenceInfo.ATTRIBUTE);
    }
  }
  return objectEl;
}

Fixed version (ground truth):
public static Element exportObject(OTDataObject dataObj,OTDataObject parent,String parentResourceName) throws Exception {
  OTID id=dataObj.getGlobalId();
  if (writtenIds.contains(id)) {
    return exportObjectReference(id);
  }
  XMLDataObject xmlDO=null;
  if (dataObj instanceof XMLDataObject) {
    xmlDO=(XMLDataObject)dataObj;
    XMLDataObject container=xmlDO.getContainer();
    if (container != null && processedIds.contains(container.getGlobalId())) {
      if (parent != container || !parentResourceName.equals(xmlDO.getContainerResourceKey())) {
        return exportObjectReference(id);
      }
    }
  }
  writtenIds.add(id);
  String objectFullClassName=OTrunkImpl.getClassName(dataObj);
  String objectElementName=getObjectElementName(objectFullClassName);
  Element objectEl=new Element(objectElementName);
  if (xmlDO != null && xmlDO.getLocalId() != null) {
    objectEl.setAttribute("String_Node_Str",xmlDO.getLocalId());
  }
 else {
    ArrayList incomingReferences=(ArrayList)incomingReferenceMap.get(id);
    if (incomingReferences != null && incomingReferences.size() > 1) {
      objectEl.setAttribute("String_Node_Str",id.toString());
    }
  }
  String resourceKeys[]=dataObj.getResourceKeys();
  for (int i=0; i < resourceKeys.length; i++) {
    String resourceName=resourceKeys[i];
    if (resourceName.equals("String_Node_Str") || resourceName.equals("String_Node_Str")) {
      continue;
    }
    Object resource=dataObj.getResource(resourceName);
    if (resource instanceof OTID) {
      Element objectIDEl=exportID(dataObj,(OTID)resource,resourceName);
      writeResourceElement(dataObj,objectEl,resourceName,objectIDEl);
    }
 else     if (resource instanceof OTDataList) {
      OTDataList list=(OTDataList)resource;
      if (list.size() == 0) {
        continue;
      }
      ArrayList content=new ArrayList();
      for (int j=0; j < list.size(); j++) {
        Object listElement=list.get(j);
        if (listElement == null) {
          System.err.println("String_Node_Str");
          continue;
        }
        if (list instanceof XMLDataList) {
          XMLReferenceInfo info=((XMLDataList)list).getReferenceInfo(j);
          if (info != null && info.comment != null) {
            content.add(new Comment(info.comment));
          }
        }
        Element collectionEl=exportCollectionItem(dataObj,listElement,resourceName);
        if (collectionEl != null) {
          content.add(collectionEl);
        }
      }
      writeResourceElement(dataObj,objectEl,resourceName,content);
    }
 else     if (resource instanceof OTDataMap) {
      OTDataMap map=(OTDataMap)resource;
      String[] mapKeys=map.getKeys();
      ArrayList content=new ArrayList();
      for (int j=0; j < mapKeys.length; j++) {
        Element entryEl=new Element("String_Node_Str");
        content.add(entryEl);
        entryEl.setAttribute("String_Node_Str",mapKeys[j]);
        Object mapValue=map.get(mapKeys[j]);
        if (mapValue != null) {
          Element collectionEl=exportCollectionItem(dataObj,mapValue,resourceName);
          entryEl.addContent(collectionEl);
        }
      }
      writeResourceElement(dataObj,objectEl,resourceName,content);
    }
 else     if (resource instanceof BlobResource) {
      BlobResource blob=(BlobResource)resource;
      Object blobUrl=blob.getBlobURL();
      String blobString=null;
      int defaultType=XMLReferenceInfo.ELEMENT;
      if (blobUrl != null) {
        blobString=blobUrl.toString();
        defaultType=XMLReferenceInfo.ATTRIBUTE;
      }
 else {
        blobString=BlobTypeHandler.base64(blob.getBytes());
      }
      writeResource(dataObj,objectEl,resourceName,blobString,defaultType);
    }
 else     if (resource == null) {
      System.err.println("String_Node_Str");
    }
 else     if (resource instanceof Integer || resource instanceof Float || resource instanceof Byte|| resource instanceof Short|| resource instanceof Boolean) {
      String primitiveString=resource.toString();
      writeResource(dataObj,objectEl,resourceName,primitiveString,XMLReferenceInfo.ATTRIBUTE);
    }
 else     if (resource instanceof OTXMLString) {
      SAXBuilder builder=new SAXBuilder();
      String xmlString="String_Node_Str" + ((OTXMLString)resource).getContent().trim() + "String_Node_Str";
      StringReader reader=new StringReader(xmlString);
      try {
        Document xmlStringDoc=builder.build(reader,resourceName);
        Element rootXMLStringEl=xmlStringDoc.getRootElement();
        writeResourceElement(dataObj,objectEl,resourceName,rootXMLStringEl.cloneContent());
      }
 catch (      JDOMParseException e) {
        System.err.println("String_Node_Str");
        System.err.println("String_Node_Str");
        System.err.println(xmlString);
        System.err.println("String_Node_Str");
        e.printStackTrace();
      }
    }
 else {
      String primitiveString=resource.toString();
      writeResource(dataObj,objectEl,resourceName,primitiveString,XMLReferenceInfo.ATTRIBUTE);
    }
  }
  return objectEl;
}