aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit/api
diff options
context:
space:
mode:
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();
}
}