diff options
author | David Pursehouse <david.pursehouse@gmail.com> | 2018-03-06 16:49:23 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@gmail.com> | 2018-03-06 16:56:13 +0900 |
commit | 209bb6ea94e56f4b56abc67d5a50f1734bfd6773 (patch) | |
tree | eb35cea9342253e62f8961a5d7d2ef136da4b9e2 /org.eclipse.jgit.test | |
parent | 159388b1a6ba10b7849c30ab2ca5005975736dd2 (diff) | |
download | jgit-209bb6ea94e56f4b56abc67d5a50f1734bfd6773.tar.gz jgit-209bb6ea94e56f4b56abc67d5a50f1734bfd6773.zip |
EGitPatchHistoryTest: Open BufferedReader in try-with-resource
Change-Id: I74aede463c7b0a478a1e0e8b680c206d3964061d
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java b/org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java index da997f98a1..3f9ef12507 100644 --- a/org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java +++ b/org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java @@ -202,28 +202,28 @@ public class EGitPatchHistoryTest { } void read() throws IOException, InterruptedException { - final BufferedReader in = new BufferedReader(new InputStreamReader( - proc.getInputStream(), ISO_8859_1)); - String commitId = null; - TemporaryBuffer buf = null; - for (;;) { - String line = in.readLine(); - if (line == null) - break; - if (line.startsWith("commit ")) { - if (buf != null) { - buf.close(); - onCommit(commitId, buf.toByteArray()); - buf.destroy(); + try (BufferedReader in = new BufferedReader( + new InputStreamReader(proc.getInputStream(), ISO_8859_1))) { + String commitId = null; + TemporaryBuffer buf = null; + for (;;) { + String line = in.readLine(); + if (line == null) + break; + if (line.startsWith("commit ")) { + if (buf != null) { + buf.close(); + onCommit(commitId, buf.toByteArray()); + buf.destroy(); + } + commitId = line.substring("commit ".length()); + buf = new TemporaryBuffer.LocalFile(null); + } else if (buf != null) { + buf.write(line.getBytes(ISO_8859_1)); + buf.write('\n'); } - commitId = line.substring("commit ".length()); - buf = new TemporaryBuffer.LocalFile(null); - } else if (buf != null) { - buf.write(line.getBytes(ISO_8859_1)); - buf.write('\n'); } } - in.close(); assertEquals(0, proc.waitFor()); proc = null; } |