Program: 11931
Project: 11931
Buggy source:
public void save(XMLResource resource,OutputStream outputStream,Map options) throws IOException {
  init(resource,options);
  List contents=resource.getContents();
  traverse(contents);
  if (encoding.equals("String_Node_Str") || encoding.equals("String_Node_Str")) {
    writeAscii(outputStream);
  }
 else {
    OutputStreamWriter outputStreamWriter=new OutputStreamWriter(outputStream,helper.getJavaEncoding(encoding));
    write(outputStreamWriter);
  }
  if (extendedMetaData != null && contents.size() >= 1) {
    EObject root=(EObject)contents.get(0);
    EClass eClass=root.eClass();
    EReference xmlnsPrefixMapFeature=extendedMetaData.getXMLNSPrefixMapFeature(eClass);
    if (xmlnsPrefixMapFeature != null) {
      EMap xmlnsPrefixMap=(EMap)root.eGet(xmlnsPrefixMapFeature);
      for (Iterator i=helper.getPrefixToNamespaceMap().iterator(); i.hasNext(); ) {
        Map.Entry entry=(Map.Entry)i.next();
        Object key=entry.getKey();
        Object value=entry.getValue();
        Object currentValue=xmlnsPrefixMap.get(key);
        if (currentValue == null ? value != null : !currentValue.equals(value)) {
          xmlnsPrefixMap.put(key,value);
        }
      }
    }
  }
  featureTable=null;
  doc=null;
  if (processDanglingHREF == null || XMLResource.OPTION_PROCESS_DANGLING_HREF_THROW.equals(processDanglingHREF)) {
    DanglingHREFException exception=helper.getDanglingHREFException();
    if (exception != null) {
      helper=null;
      throw new Resource.IOWrappedException(exception);
    }
  }
  helper=null;
}

Fixed version (ground truth):
public void save(XMLResource resource,OutputStream outputStream,Map options) throws IOException {
  init(resource,options);
  List contents=resource.getContents();
  traverse(contents);
  if (encoding.equals("String_Node_Str") || encoding.equals("String_Node_Str")) {
    writeAscii(outputStream);
    outputStream.flush();
  }
 else {
    OutputStreamWriter outputStreamWriter=new OutputStreamWriter(outputStream,helper.getJavaEncoding(encoding));
    write(outputStreamWriter);
    outputStreamWriter.flush();
  }
  if (extendedMetaData != null && contents.size() >= 1) {
    EObject root=(EObject)contents.get(0);
    EClass eClass=root.eClass();
    EReference xmlnsPrefixMapFeature=extendedMetaData.getXMLNSPrefixMapFeature(eClass);
    if (xmlnsPrefixMapFeature != null) {
      EMap xmlnsPrefixMap=(EMap)root.eGet(xmlnsPrefixMapFeature);
      for (Iterator i=helper.getPrefixToNamespaceMap().iterator(); i.hasNext(); ) {
        Map.Entry entry=(Map.Entry)i.next();
        Object key=entry.getKey();
        Object value=entry.getValue();
        Object currentValue=xmlnsPrefixMap.get(key);
        if (currentValue == null ? value != null : !currentValue.equals(value)) {
          xmlnsPrefixMap.put(key,value);
        }
      }
    }
  }
  featureTable=null;
  doc=null;
  if (processDanglingHREF == null || XMLResource.OPTION_PROCESS_DANGLING_HREF_THROW.equals(processDanglingHREF)) {
    DanglingHREFException exception=helper.getDanglingHREFException();
    if (exception != null) {
      helper=null;
      throw new Resource.IOWrappedException(exception);
    }
  }
  helper=null;
}