summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2018-02-26 17:48:42 +0900
committerDavid Pursehouse <david.pursehouse@gmail.com>2018-02-26 17:48:42 +0900
commitc2ff87e7869cad38d0ee505033d9439270b816d8 (patch)
treea953a192a4587be73a5d681404979cc7974e7a2c /org.eclipse.jgit.test
parent8212924ede452789b7c71f32bf26be905228357a (diff)
downloadjgit-c2ff87e7869cad38d0ee505033d9439270b816d8.tar.gz
jgit-c2ff87e7869cad38d0ee505033d9439270b816d8.zip
MergeGitAttributeTest: Open FileInputStream in try-with-resource
Change-Id: Iec85eea044c46a199b5b6f6bdbb3191d817dd441 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/attributes/merge/MergeGitAttributeTest.java44
1 files changed, 17 insertions, 27 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/merge/MergeGitAttributeTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/merge/MergeGitAttributeTest.java
index a4f3d18d1f..01ca88880f 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/merge/MergeGitAttributeTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/merge/MergeGitAttributeTest.java
@@ -313,7 +313,6 @@ public class MergeGitAttributeTest extends RepositoryTestCase {
WrongRepositoryStateException, NoMessageException, GitAPIException {
RevCommit disableCheckedCommit;
- FileInputStream mergeResultFile = null;
// Set up a git with conflict commits on images
try (Git git = new Git(db)) {
// First commit
@@ -352,15 +351,12 @@ public class MergeGitAttributeTest extends RepositoryTestCase {
assertEquals(MergeStatus.CONFLICTING, mergeResult.getMergeStatus());
// Check that the image was not modified (no conflict marker added)
- mergeResultFile = new FileInputStream(
+ try (FileInputStream mergeResultFile = new FileInputStream(
db.getWorkTree().toPath().resolve(ENABLED_CHECKED_GIF)
- .toFile());
- assertTrue(contentEquals(
- getClass().getResourceAsStream(ENABLED_CHECKED_GIF),
- mergeResultFile));
- } finally {
- if (mergeResultFile != null) {
- mergeResultFile.close();
+ .toFile())) {
+ assertTrue(contentEquals(
+ getClass().getResourceAsStream(ENABLED_CHECKED_GIF),
+ mergeResultFile));
}
}
}
@@ -373,7 +369,6 @@ public class MergeGitAttributeTest extends RepositoryTestCase {
WrongRepositoryStateException, NoMessageException, GitAPIException {
RevCommit disableCheckedCommit;
- FileInputStream mergeResultFile = null;
// Set up a git whith conflict commits on images
try (Git git = new Git(db)) {
// First commit
@@ -412,14 +407,12 @@ public class MergeGitAttributeTest extends RepositoryTestCase {
assertEquals(MergeStatus.CONFLICTING, mergeResult.getMergeStatus());
// Check that the image was not modified (not conflict marker added)
- mergeResultFile = new FileInputStream(db.getWorkTree().toPath()
- .resolve(ENABLED_CHECKED_GIF).toFile());
- assertTrue(contentEquals(
- getClass().getResourceAsStream(ENABLED_CHECKED_GIF),
- mergeResultFile));
- } finally {
- if (mergeResultFile != null) {
- mergeResultFile.close();
+ try (FileInputStream mergeResultFile = new FileInputStream(
+ db.getWorkTree().toPath().resolve(ENABLED_CHECKED_GIF)
+ .toFile())) {
+ assertTrue(contentEquals(
+ getClass().getResourceAsStream(ENABLED_CHECKED_GIF),
+ mergeResultFile));
}
}
}
@@ -432,7 +425,6 @@ public class MergeGitAttributeTest extends RepositoryTestCase {
NoMessageException, GitAPIException {
RevCommit disableCheckedCommit;
- FileInputStream mergeResultFile = null;
// Set up a git whith conflict commits on images
try (Git git = new Git(db)) {
// First commit
@@ -471,14 +463,12 @@ public class MergeGitAttributeTest extends RepositoryTestCase {
assertEquals(MergeStatus.CONFLICTING, mergeResult.getMergeStatus());
// Check that the image was not modified (not conflict marker added)
- mergeResultFile = new FileInputStream(db.getWorkTree().toPath()
- .resolve(ENABLED_CHECKED_GIF).toFile());
- assertFalse(contentEquals(
- getClass().getResourceAsStream(ENABLED_CHECKED_GIF),
- mergeResultFile));
- } finally {
- if (mergeResultFile != null) {
- mergeResultFile.close();
+ try (FileInputStream mergeResultFile = new FileInputStream(
+ db.getWorkTree().toPath().resolve(ENABLED_CHECKED_GIF)
+ .toFile())) {
+ assertFalse(contentEquals(
+ getClass().getResourceAsStream(ENABLED_CHECKED_GIF),
+ mergeResultFile));
}
}
}