Program: 21636
Project: 21636
Buggy source:
public static void export(Writer writer,OTDataObject rootObject,OTDatabase db) throws Exception {
  writtenIds=new ArrayList();
  processedClasses=new ArrayList();
  duplicateClasses=new ArrayList();
  containers=new HashMap();
  processedIds=new ArrayList();
  incomingReferenceMap=new HashMap();
  if (db instanceof XMLDatabase) {
    ArrayList importedClasses=((XMLDatabase)db).getImportedOTObjectClasses();
    processedClasses.addAll(importedClasses);
  }
  otDb=db;
  processObject(rootObject);
  Element rootObjectElement=null;
  try {
    rootObjectElement=exportObject(rootObject,null,null);
  }
 catch (  Exception e) {
    throw e;
  }
  Element otrunkEl=new Element("String_Node_Str");
  otrunkEl.setAttribute("String_Node_Str",otDb.getDatabaseId().toString());
  Element importsEl=new Element("String_Node_Str");
  otrunkEl.addContent(importsEl);
  for (int i=0; i < processedClasses.size(); i++) {
    Element importEl=new Element("String_Node_Str");
    importsEl.addContent(importEl);
    importEl.setAttribute("String_Node_Str",(String)processedClasses.get(i));
  }
  Element objectsEl=new Element("String_Node_Str");
  otrunkEl.addContent(objectsEl);
  objectsEl.addContent(rootObjectElement);
  Document doc=new Document(otrunkEl);
  Format format=Format.getPrettyFormat();
  XMLOutputter outputter=new XMLOutputter(format);
  if (saveFile != null) {
    System.out.println("String_Node_Str");
    FileOutputStream outputStream=new FileOutputStream(saveFile);
    OutputStreamWriter outputStreamWriter=new OutputStreamWriter(outputStream,"String_Node_Str");
    outputter.output(doc,outputStreamWriter);
    outputStreamWriter.close();
    writer.close();
  }
 else {
    System.out.println("String_Node_Str");
    outputter.output(doc,writer);
    writer.close();
  }
}

Fixed version (ground truth):
public static void export(Writer writer,OTDataObject rootObject,OTDatabase db) throws Exception {
  writtenIds=new ArrayList();
  processedClasses=new ArrayList();
  duplicateClasses=new ArrayList();
  containers=new HashMap();
  processedIds=new ArrayList();
  incomingReferenceMap=new HashMap();
  if (db instanceof XMLDatabase) {
    ArrayList importedClasses=((XMLDatabase)db).getImportedOTObjectClasses();
    processedClasses.addAll(importedClasses);
  }
  otDb=db;
  processObject(rootObject);
  Element rootObjectElement=null;
  try {
    rootObjectElement=exportObject(rootObject,null,null);
  }
 catch (  Exception e) {
    throw e;
  }
  Element otrunkEl=new Element("String_Node_Str");
  OTID dbID=otDb.getDatabaseId();
  if (dbID == null) {
    dbID=OTUUID.createOTUUID();
  }
  otrunkEl.setAttribute("String_Node_Str",otDb.getDatabaseId().toExternalForm());
  Element importsEl=new Element("String_Node_Str");
  otrunkEl.addContent(importsEl);
  for (int i=0; i < processedClasses.size(); i++) {
    Element importEl=new Element("String_Node_Str");
    importsEl.addContent(importEl);
    importEl.setAttribute("String_Node_Str",(String)processedClasses.get(i));
  }
  Element objectsEl=new Element("String_Node_Str");
  otrunkEl.addContent(objectsEl);
  objectsEl.addContent(rootObjectElement);
  Document doc=new Document(otrunkEl);
  Format format=Format.getPrettyFormat();
  XMLOutputter outputter=new XMLOutputter(format);
  if (saveFile != null) {
    System.out.println("String_Node_Str");
    FileOutputStream outputStream=new FileOutputStream(saveFile);
    OutputStreamWriter outputStreamWriter=new OutputStreamWriter(outputStream,"String_Node_Str");
    outputter.output(doc,outputStreamWriter);
    outputStreamWriter.close();
    writer.close();
  }
 else {
    System.out.println("String_Node_Str");
    outputter.output(doc,writer);
    writer.close();
  }
}