Browse Source

LockFile: Open FileInputStream in try-with-resource

Change-Id: I0784266814225428a6a0070d1653c465d268b342
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-4.11
David Pursehouse 7 years ago
parent
commit
20b750d2f5
  1. 5
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java

5
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java

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

Loading…
Cancel
Save