]> source.dussan.org Git - jgit.git/commitdiff
DiffFormatterReflowTest: Open InputStream in try-with-resource 38/118738/3
authorDavid Pursehouse <david.pursehouse@gmail.com>
Tue, 6 Mar 2018 01:42:36 +0000 (10:42 +0900)
committerDavid Pursehouse <david.pursehouse@gmail.com>
Tue, 6 Mar 2018 07:56:12 +0000 (16:56 +0900)
Change-Id: Id7f420a2eac57e59fa3feb04236df6f5f8d07f02
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/DiffFormatterReflowTest.java

index 31f70cf28c1675c06c267503f8331b77f7192f52..49e5d1b3d4f75ccafcf8a03bc0f7ac32185b9932 100644 (file)
@@ -181,17 +181,14 @@ public class DiffFormatterReflowTest {
        }
 
        private Patch parseTestPatchFile(final String patchFile) throws IOException {
-               final InputStream in = getClass().getResourceAsStream(patchFile);
-               if (in == null) {
-                       fail("No " + patchFile + " test vector");
-                       return null; // Never happens
-               }
-               try {
+               try (InputStream in = getClass().getResourceAsStream(patchFile)) {
+                       if (in == null) {
+                               fail("No " + patchFile + " test vector");
+                               return null; // Never happens
+                       }
                        final Patch p = new Patch();
                        p.parse(in);
                        return p;
-               } finally {
-                       in.close();
                }
        }
 }