Browse Source

DirCacheCGitCompatabilityTest: Open BufferedReader in try-with-resource

Change-Id: I0494eb475954927743174941a7d6c06d8431f57f
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-4.11
David Pursehouse 7 years ago
parent
commit
50cebd85a8
  1. 14
      org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java

14
org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java vendored

@ -234,32 +234,26 @@ public class DirCacheCGitCompatabilityTest extends LocalDiskRepositoryTestCase {
private static Map<String, CGitIndexRecord> readLsFiles() throws Exception { private static Map<String, CGitIndexRecord> readLsFiles() throws Exception {
final LinkedHashMap<String, CGitIndexRecord> r = new LinkedHashMap<>(); final LinkedHashMap<String, CGitIndexRecord> r = new LinkedHashMap<>();
final BufferedReader br = new BufferedReader(new InputStreamReader( try (BufferedReader br = new BufferedReader(new InputStreamReader(
new FileInputStream(pathOf("gitgit.lsfiles")), "UTF-8")); new FileInputStream(pathOf("gitgit.lsfiles")), "UTF-8"))) {
try {
String line; String line;
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
final CGitIndexRecord cr = new CGitIndexRecord(line); final CGitIndexRecord cr = new CGitIndexRecord(line);
r.put(cr.path, cr); r.put(cr.path, cr);
} }
} finally {
br.close();
} }
return r; return r;
} }
private static Map<String, CGitLsTreeRecord> readLsTree() throws Exception { private static Map<String, CGitLsTreeRecord> readLsTree() throws Exception {
final LinkedHashMap<String, CGitLsTreeRecord> r = new LinkedHashMap<>(); final LinkedHashMap<String, CGitLsTreeRecord> r = new LinkedHashMap<>();
final BufferedReader br = new BufferedReader(new InputStreamReader( try (BufferedReader br = new BufferedReader(new InputStreamReader(
new FileInputStream(pathOf("gitgit.lstree")), "UTF-8")); new FileInputStream(pathOf("gitgit.lstree")), "UTF-8"))) {
try {
String line; String line;
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
final CGitLsTreeRecord cr = new CGitLsTreeRecord(line); final CGitLsTreeRecord cr = new CGitLsTreeRecord(line);
r.put(cr.path, cr); r.put(cr.path, cr);
} }
} finally {
br.close();
} }
return r; return r;
} }

Loading…
Cancel
Save