diff options
author | David Pursehouse <david.pursehouse@gmail.com> | 2018-02-26 17:42:38 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@gmail.com> | 2018-02-26 17:45:11 +0900 |
commit | 8212924ede452789b7c71f32bf26be905228357a (patch) | |
tree | d176e747cf0951cc9a969a19526fc22666bf8fd0 /org.eclipse.jgit.test | |
parent | ca7d3e27342dfd98b041dc12a3094408f08b554d (diff) | |
download | jgit-8212924ede452789b7c71f32bf26be905228357a.tar.gz jgit-8212924ede452789b7c71f32bf26be905228357a.zip |
PullCommandWithRebaseTest: Open File{Input|Output}Stream in try-with-resource
Change-Id: I1ff707ab7bab676603907f4c0bb1bc495503055b
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java index dfe05b808e..7881857b30 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java @@ -395,24 +395,16 @@ public class PullCommandWithRebaseTest extends RepositoryTestCase { private static void writeToFile(File actFile, String string) throws IOException { - FileOutputStream fos = null; - try { - fos = new FileOutputStream(actFile); + try (FileOutputStream fos = new FileOutputStream(actFile)) { fos.write(string.getBytes(UTF_8)); - fos.close(); - } finally { - if (fos != null) - fos.close(); } } private static void assertFileContentsEqual(File actFile, String string) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); - FileInputStream fis = null; byte[] buffer = new byte[100]; - try { - fis = new FileInputStream(actFile); + try (FileInputStream fis = new FileInputStream(actFile)) { int read = fis.read(buffer); while (read > 0) { bos.write(buffer, 0, read); @@ -420,9 +412,6 @@ public class PullCommandWithRebaseTest extends RepositoryTestCase { } String content = new String(bos.toByteArray(), "UTF-8"); assertEquals(string, content); - } finally { - if (fis != null) - fis.close(); } } } |