Browse Source

ObjectDirectory: Open BufferedReader in try-with-resource

Change-Id: I4a44954c61647af1e48eade19112697e79297f2e
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-4.11
David Pursehouse 7 years ago committed by Matthias Sohn
parent
commit
db0b7911fe
  1. 10
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java

10
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java

@ -796,8 +796,7 @@ public class ObjectDirectory extends FileObjectDatabase {
|| shallowFileSnapshot.isModified(shallowFile)) { || shallowFileSnapshot.isModified(shallowFile)) {
shallowCommitsIds = new HashSet<>(); shallowCommitsIds = new HashSet<>();
final BufferedReader reader = open(shallowFile); try (BufferedReader reader = open(shallowFile)) {
try {
String line; String line;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
try { try {
@ -807,8 +806,6 @@ public class ObjectDirectory extends FileObjectDatabase {
.format(JGitText.get().badShallowLine, line)); .format(JGitText.get().badShallowLine, line));
} }
} }
} finally {
reader.close();
} }
shallowFileSnapshot = FileSnapshot.save(shallowFile); shallowFileSnapshot = FileSnapshot.save(shallowFile);
@ -1027,14 +1024,11 @@ public class ObjectDirectory extends FileObjectDatabase {
private AlternateHandle[] loadAlternates() throws IOException { private AlternateHandle[] loadAlternates() throws IOException {
final List<AlternateHandle> l = new ArrayList<>(4); final List<AlternateHandle> l = new ArrayList<>(4);
final BufferedReader br = open(alternatesFile); try (BufferedReader br = open(alternatesFile)) {
try {
String line; String line;
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
l.add(openAlternate(line)); l.add(openAlternate(line));
} }
} finally {
br.close();
} }
return l.toArray(new AlternateHandle[l.size()]); return l.toArray(new AlternateHandle[l.size()]);
} }

Loading…
Cancel
Save