summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2018-03-05 11:03:21 +0900
committerDavid Pursehouse <david.pursehouse@gmail.com>2018-03-05 11:03:21 +0900
commit20b750d2f5d46bcd77a70b9181e3c246ed16dfa1 (patch)
tree9d6a34d6fe58125b9a8ee00757e55d98be8ce370
parentb498bc2a0e770272399ac407cdbc9171ab2d0ae7 (diff)
downloadjgit-20b750d2f5d46bcd77a70b9181e3c246ed16dfa1.tar.gz
jgit-20b750d2f5d46bcd77a70b9181e3c246ed16dfa1.zip
LockFile: Open FileInputStream in try-with-resource
Change-Id: I0784266814225428a6a0070d1653c465d268b342 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java5
1 files changed, 1 insertions, 4 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java
index 3460913e9c..bc23dcce27 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java
@@ -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()) {