]> source.dussan.org Git - jgit.git/commitdiff
EGitPatchHistoryTest: Open BufferedReader in try-with-resource 48/118748/2
authorDavid Pursehouse <david.pursehouse@gmail.com>
Tue, 6 Mar 2018 07:49:23 +0000 (16:49 +0900)
committerDavid Pursehouse <david.pursehouse@gmail.com>
Tue, 6 Mar 2018 07:56:13 +0000 (16:56 +0900)
Change-Id: I74aede463c7b0a478a1e0e8b680c206d3964061d
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java

index da997f98a178a07e2ff095e02851fd30210f082e..3f9ef12507a3a834bb6e623c24613fdaaf638f64 100644 (file)
@@ -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;
                }