]> source.dussan.org Git - jgit.git/commitdiff
LockFile: Open FileInputStream in try-with-resource 20/118620/1
authorDavid Pursehouse <david.pursehouse@gmail.com>
Mon, 5 Mar 2018 02:03:21 +0000 (11:03 +0900)
committerDavid Pursehouse <david.pursehouse@gmail.com>
Mon, 5 Mar 2018 02:03:21 +0000 (11:03 +0900)
Change-Id: I0784266814225428a6a0070d1653c465d268b342
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java

index 3460913e9c8471c79076f1aa163231c55b4f1e6d..bc23dcce27a0b1dc17baf6f4d447248624f9a8bf 100644 (file)
@@ -221,8 +221,7 @@ public class LockFile {
        public void copyCurrentContent() throws IOException {
                requireLock();
                try {
-                       final FileInputStream fis = new FileInputStream(ref);
-                       try {
+                       try (FileInputStream fis = new FileInputStream(ref)) {
                                if (fsync) {
                                        FileChannel in = fis.getChannel();
                                        long pos = 0;
@@ -238,8 +237,6 @@ public class LockFile {
                                        while ((r = fis.read(buf)) >= 0)
                                                os.write(buf, 0, r);
                                }
-                       } finally {
-                               fis.close();
                        }
                } catch (FileNotFoundException fnfe) {
                        if (ref.exists()) {