aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit/api
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2018-03-05 10:59:43 +0900
committerDavid Pursehouse <david.pursehouse@gmail.com>2018-03-05 10:59:43 +0900
commitb498bc2a0e770272399ac407cdbc9171ab2d0ae7 (patch)
tree69a6729600cb5802ce7f97c4046fc8a853e2e755 /org.eclipse.jgit.test/tst/org/eclipse/jgit/api
parent52383c29199b35120bd6d139df2d212e79e87c7c (diff)
downloadjgit-b498bc2a0e770272399ac407cdbc9171ab2d0ae7.tar.gz
jgit-b498bc2a0e770272399ac407cdbc9171ab2d0ae7.zip
CheckoutCommandTest: Open FileInputStream in try-with-resource
Change-Id: I972958373ceaf4c3ae756559ccbc341506d4e72d Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/api')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java10
1 files changed, 2 insertions, 8 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java
index 4f0f2a7fb0..71df59e1ff 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java
@@ -170,15 +170,12 @@ public class CheckoutCommandTest extends RepositoryTestCase {
@Test
public void testCheckoutWithNonDeletedFiles() throws Exception {
File testFile = writeTrashFile("temp", "");
- FileInputStream fis = new FileInputStream(testFile);
- try {
+ try (FileInputStream fis = new FileInputStream(testFile)) {
FileUtils.delete(testFile);
return;
} catch (IOException e) {
// the test makes only sense if deletion of
// a file with open stream fails
- } finally {
- fis.close();
}
FileUtils.delete(testFile);
CheckoutCommand co = git.checkout();
@@ -192,15 +189,12 @@ public class CheckoutCommandTest extends RepositoryTestCase {
git.checkout().setName("master").call();
assertTrue(testFile.exists());
// lock the file so it can't be deleted (in Windows, that is)
- fis = new FileInputStream(testFile);
- try {
+ try (FileInputStream fis = new FileInputStream(testFile)) {
assertEquals(Status.NOT_TRIED, co.getResult().getStatus());
co.setName("test").call();
assertTrue(testFile.exists());
assertEquals(Status.NONDELETED, co.getResult().getStatus());
assertTrue(co.getResult().getUndeletedList().contains("Test.txt"));
- } finally {
- fis.close();
}
}