]> source.dussan.org Git - jgit.git/commitdiff
Use try-with-resources and BufferedOutputStream for local merge conflicts 64/45064/1
authorShawn Pearce <spearce@spearce.org>
Wed, 1 Apr 2015 19:52:14 +0000 (12:52 -0700)
committerShawn Pearce <spearce@spearce.org>
Wed, 1 Apr 2015 20:02:08 +0000 (13:02 -0700)
Change-Id: If5539aab1de19bb22400c862bbe2cdf7c3e85535

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

index 6b87e645f89e8213e036299f3a03e30fb1f5ac9c..923224b316f81094fa340ec651984bd63c07310b 100644 (file)
@@ -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;
        }