Program: 11721
Project: 11721
Buggy source:
@Override protected IStatus run(IProgressMonitor monitor){
  try {
    Map<URI,URI> uriMap=resourceSet.getURIConverter().getURIMap();
    Map<URI,URI> copyiedURIMap=new HashMap<URI,URI>(uriMap);
    uriMap.clear();
    outputResource.save(options);
    uriMap.putAll(copyiedURIMap);
    outputResource.unload();
    outputResource.load(null);
    IParseResult parseResult=outputResource.getParseResult();
    if (parseResult != null) {
      IPreferenceValues configuration=preferencesProvider.getPreferenceValues(outputResource);
      try {
        List<TextReplacement> edits=formatter.format(outputResource,0,parseResult.getRootNode().getLength(),new FormattingPreferenceValues(configuration));
        BufferedInputStream bufferedInputStream=new BufferedInputStream(resourceSet.getURIConverter().createInputStream(outputResource.getURI()));
        byte[] input=new byte[bufferedInputStream.available()];
        bufferedInputStream.read(input);
        bufferedInputStream.close();
        String text=new String(input,outputResource.getEncoding());
        StringBuilder builder=new StringBuilder(text);
        for (int i=edits.size(); --i >= 0; ) {
          TextReplacement replacement=edits.get(i);
          builder.replace(replacement.getOffset(),replacement.getOffset() + replacement.getLength(),replacement.getText());
        }
        OutputStream outputStream=resourceSet.getURIConverter().createOutputStream(outputResource.getURI());
        outputStream.write(builder.toString().getBytes(outputResource.getEncoding()));
        outputStream.close();
      }
 catch (      Throwable throwable) {
        XcoreExporterPlugin.INSTANCE.log(throwable);
      }
    }
  }
 catch (  IOException exception) {
    return Status.CANCEL_STATUS;
  }
  return Status.OK_STATUS;
}

Fixed version (ground truth):
@Override protected IStatus run(IProgressMonitor monitor){
  try {
    Map<URI,URI> copyiedURIMap=new HashMap<URI,URI>(uriMap);
    uriMap.clear();
    outputResource.save(options);
    uriMap.putAll(copyiedURIMap);
    outputResource.unload();
    outputResource.load(null);
    IParseResult parseResult=outputResource.getParseResult();
    if (parseResult != null) {
      IPreferenceValues configuration=preferencesProvider.getPreferenceValues(outputResource);
      try {
        List<TextReplacement> edits=formatter.format(outputResource,0,parseResult.getRootNode().getLength(),new FormattingPreferenceValues(configuration));
        BufferedInputStream bufferedInputStream=new BufferedInputStream(resourceSet.getURIConverter().createInputStream(outputResource.getURI()));
        byte[] input=new byte[bufferedInputStream.available()];
        bufferedInputStream.read(input);
        bufferedInputStream.close();
        String text=new String(input,outputResource.getEncoding());
        StringBuilder builder=new StringBuilder(text);
        for (int i=edits.size(); --i >= 0; ) {
          TextReplacement replacement=edits.get(i);
          builder.replace(replacement.getOffset(),replacement.getOffset() + replacement.getLength(),replacement.getText());
        }
        OutputStream outputStream=resourceSet.getURIConverter().createOutputStream(outputResource.getURI());
        outputStream.write(builder.toString().getBytes(outputResource.getEncoding()));
        outputStream.close();
      }
 catch (      Throwable throwable) {
        XcoreExporterPlugin.INSTANCE.log(throwable);
      }
    }
  }
 catch (  IOException exception) {
    return Status.CANCEL_STATUS;
  }
  return Status.OK_STATUS;
}