Browse Source

Use try-with-resources and BufferedOutputStream for local merge conflicts

Change-Id: If5539aab1de19bb22400c862bbe2cdf7c3e85535
stable-4.1
Shawn Pearce 10 years ago
parent
commit
835955fc5b
  1. 10
      org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java

10
org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java

@ -47,12 +47,14 @@ package org.eclipse.jgit.merge;
import static org.eclipse.jgit.lib.Constants.CHARACTER_ENCODING;
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -792,12 +794,10 @@ public class ResolveMerger extends ThreeWayMerger {
File parentFolder = of.getParentFile();
if (!fs.exists(parentFolder))
parentFolder.mkdirs();
FileOutputStream fos = new FileOutputStream(of);
try {
new MergeFormatter().formatMerge(fos, result,
try (OutputStream os = new BufferedOutputStream(
new FileOutputStream(of))) {
new MergeFormatter().formatMerge(os, result,
Arrays.asList(commitNames), CHARACTER_ENCODING);
} finally {
fos.close();
}
return of;
}

Loading…
Cancel
Save