Program: 21611
Project: 21611
Buggy source:
public Element exportObject(OTDataObject dataObj,OTDataObject parent,String parentResourceName) throws Exception {
  OTID id=dataObj.getGlobalId();
  if (shouldWriteReference(dataObj,parent,parentResourceName)) {
    return exportObjectReference(id);
  }
  writtenIds.add(id);
  String objectFullClassName=OTrunkImpl.getClassName(dataObj);
  String objectElementName=getObjectElementName(objectFullClassName);
  Element objectEl=new Element(objectElementName);
  XMLDataObject xmlDO=null;
  if (dataObj instanceof XMLDataObject) {
    xmlDO=(XMLDataObject)dataObj;
  }
  if (xmlDO != null && xmlDO.getLocalId() != null) {
    objectEl.setAttribute("String_Node_Str",xmlDO.getLocalId());
  }
 else {
    ArrayList incomingReferences=(ArrayList)incomingReferenceMap.get(id);
    if ((xmlDO != null && xmlDO.isPreserveUUID() && id instanceof OTUUID) || (incomingReferences != null && incomingReferences.size() > 1)) {
      objectEl.setAttribute("String_Node_Str",id.toExternalForm());
    }
  }
  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 (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);
        String exportedKey=mapKeys[j];
        try {
          OTID otid=OTIDFactory.createOTID(mapKeys[j]);
          if (otid != null) {
            if (isLocalId(otid)) {
              exportedKey=convertId(otid);
            }
          }
        }
 catch (        Throwable t) {
        }
        entryEl.setAttribute("String_Node_Str",exportedKey);
        Object mapValue=map.get(mapKeys[j]);
        Element collectionEl=exportCollectionItem(dataObj,mapValue,resourceName);
        entryEl.addContent(collectionEl);
      }
      writeResourceElement(dataObj,objectEl,resourceName,content);
    }
 else     if (resource instanceof BlobResource) {
      BlobResource blob=(BlobResource)resource;
      URL blobUrl=blob.getBlobURL();
      String blobString=null;
      int defaultType=XMLReferenceInfo.ELEMENT;
      if (blobUrl != null) {
        if (contextURL != null) {
          blobString=URLUtil.getRelativeURL(contextURL,blobUrl);
        }
 else {
          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) {
      String xmlString=((OTXMLString)resource).getContent();
      xmlString=exportXMLString(refidPattern,xmlString);
      xmlString=exportXMLString(viewidPattern,xmlString);
      xmlString=exportXMLString(hrefPattern,xmlString);
      String originalString=xmlString.trim();
      SAXBuilder builder=new SAXBuilder();
      xmlString="String_Node_Str" + originalString + "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" + e.getCause());
        System.err.println("String_Node_Str");
        System.err.println("String_Node_Str");
        System.err.println(xmlString);
        System.err.println("String_Node_Str");
        String warning="String_Node_Str" + e.getCause();
        Object[] options={"String_Node_Str","String_Node_Str"};
        boolean saveAnyway=JOptionPane.showOptionDialog(null,warning,"String_Node_Str",JOptionPane.YES_NO_OPTION,JOptionPane.ERROR_MESSAGE,null,options,options[1]) == 0;
        if (!saveAnyway) {
          throw new Exception("String_Node_Str");
        }
 else {
          writeResource(dataObj,objectEl,resourceName,XMLStringTypeHandler.INVALID_PREFIX + originalString,XMLReferenceInfo.ELEMENT);
        }
        e.printStackTrace();
      }
    }
 else     if (resource instanceof String) {
      writeResource(dataObj,objectEl,resourceName,(String)resource,XMLReferenceInfo.ATTRIBUTE);
    }
 else {
      String primitiveString=resource.toString();
      writeResource(dataObj,objectEl,resourceName,primitiveString,XMLReferenceInfo.ATTRIBUTE);
    }
  }
  return objectEl;
}

Fixed version (ground truth):
public Element exportObject(OTDataObject dataObj,OTDataObject parent,String parentResourceName) throws Exception {
  OTID id=dataObj.getGlobalId();
  if (shouldWriteReference(dataObj,parent,parentResourceName)) {
    return exportObjectReference(id);
  }
  writtenIds.add(id);
  String objectFullClassName=OTrunkImpl.getClassName(dataObj);
  String objectElementName=getObjectElementName(objectFullClassName);
  Element objectEl=new Element(objectElementName);
  XMLDataObject xmlDO=null;
  if (dataObj instanceof XMLDataObject) {
    xmlDO=(XMLDataObject)dataObj;
  }
  if (xmlDO != null && xmlDO.getLocalId() != null) {
    objectEl.setAttribute("String_Node_Str",xmlDO.getLocalId());
  }
 else {
    ArrayList incomingReferences=(ArrayList)incomingReferenceMap.get(id);
    if ((xmlDO != null && xmlDO.isPreserveUUID() && id instanceof OTUUID) || (incomingReferences != null && incomingReferences.size() > 1)) {
      objectEl.setAttribute("String_Node_Str",id.toExternalForm());
    }
  }
  String resourceKeys[]=dataObj.getResourceKeys();
  ArrayList nullResources=new ArrayList();
  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 (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);
        String exportedKey=mapKeys[j];
        try {
          OTID otid=OTIDFactory.createOTID(mapKeys[j]);
          if (otid != null) {
            if (isLocalId(otid)) {
              exportedKey=convertId(otid);
            }
          }
        }
 catch (        Throwable t) {
        }
        entryEl.setAttribute("String_Node_Str",exportedKey);
        Object mapValue=map.get(mapKeys[j]);
        Element collectionEl=exportCollectionItem(dataObj,mapValue,resourceName);
        entryEl.addContent(collectionEl);
      }
      writeResourceElement(dataObj,objectEl,resourceName,content);
    }
 else     if (resource instanceof BlobResource) {
      BlobResource blob=(BlobResource)resource;
      URL blobUrl=blob.getBlobURL();
      String blobString=null;
      int defaultType=XMLReferenceInfo.ELEMENT;
      if (blobUrl != null) {
        if (contextURL != null) {
          blobString=URLUtil.getRelativeURL(contextURL,blobUrl);
        }
 else {
          blobString=blobUrl.toString();
        }
        defaultType=XMLReferenceInfo.ATTRIBUTE;
      }
 else {
        blobString=BlobTypeHandler.base64(blob.getBytes());
      }
      writeResource(dataObj,objectEl,resourceName,blobString,defaultType);
    }
 else     if (resource == null) {
      if (xmlDO.getSaveNulls()) {
        nullResources.add(resourceName);
      }
 else {
        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) {
      String xmlString=((OTXMLString)resource).getContent();
      xmlString=exportXMLString(refidPattern,xmlString);
      xmlString=exportXMLString(viewidPattern,xmlString);
      xmlString=exportXMLString(hrefPattern,xmlString);
      String originalString=xmlString.trim();
      SAXBuilder builder=new SAXBuilder();
      xmlString="String_Node_Str" + originalString + "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" + e.getCause());
        System.err.println("String_Node_Str");
        System.err.println("String_Node_Str");
        System.err.println(xmlString);
        System.err.println("String_Node_Str");
        String warning="String_Node_Str" + e.getCause();
        Object[] options={"String_Node_Str","String_Node_Str"};
        boolean saveAnyway=JOptionPane.showOptionDialog(null,warning,"String_Node_Str",JOptionPane.YES_NO_OPTION,JOptionPane.ERROR_MESSAGE,null,options,options[1]) == 0;
        if (!saveAnyway) {
          throw new Exception("String_Node_Str");
        }
 else {
          writeResource(dataObj,objectEl,resourceName,XMLStringTypeHandler.INVALID_PREFIX + originalString,XMLReferenceInfo.ELEMENT);
        }
        e.printStackTrace();
      }
    }
 else     if (resource instanceof String) {
      writeResource(dataObj,objectEl,resourceName,(String)resource,XMLReferenceInfo.ATTRIBUTE);
    }
 else {
      String primitiveString=resource.toString();
      writeResource(dataObj,objectEl,resourceName,primitiveString,XMLReferenceInfo.ATTRIBUTE);
    }
  }
  if (nullResources.size() > 0) {
    String unsetList="String_Node_Str";
    for (int i=0; i < nullResources.size(); i++) {
      unsetList+=nullResources.get(i) + "String_Node_Str";
    }
    unsetList=unsetList.trim();
    objectEl.setAttribute("String_Node_Str",unsetList);
  }
  return objectEl;
}