aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2018-09-27 18:01:03 +0900
committerDavid Pursehouse <david.pursehouse@gmail.com>2018-09-27 18:01:03 +0900
commitb2ee02f53b75f1358f5784d60880f5a4be9a1d72 (patch)
tree8d3d7ed939dd7b13329ba54b82856b2d70a8423c /org.eclipse.jgit.test
parentfa61fd6f61de2ff997c791154bbaf1dc00ee96b9 (diff)
downloadjgit-b2ee02f53b75f1358f5784d60880f5a4be9a1d72.tar.gz
jgit-b2ee02f53b75f1358f5784d60880f5a4be9a1d72.zip
FileRepositoryBuilderTest: Don't explicitly close BufferedWriter in try-with-resource
The BufferedWriter is opened in a try-with-resource and thus will be automatically closed. Presumably the close was added to make sure it is closed before the subsequent test statements are executed. Instead of explicitly closing it, let the try-with-resource automatically close it, and move the subsequent statements out of the try-block. Change-Id: If5fada2f580ef9cbaad3a0b9216b5200b917781a 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/internal/storage/file/FileRepositoryBuilderTest.java69
1 files changed, 34 insertions, 35 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java
index 3697050bb8..f6cb55870b 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java
@@ -124,17 +124,17 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase {
File dotGit = new File(dir, Constants.DOT_GIT);
try (BufferedWriter writer = Files.newBufferedWriter(dotGit.toPath(),
UTF_8)) {
- writer.append("gitdir: " + repo1.getDirectory().getAbsolutePath()).close();
- FileRepositoryBuilder builder = new FileRepositoryBuilder();
+ writer.append("gitdir: " + repo1.getDirectory().getAbsolutePath());
+ }
+ FileRepositoryBuilder builder = new FileRepositoryBuilder();
- builder.setWorkTree(dir);
- builder.setMustExist(true);
- Repository repo2 = builder.build();
+ builder.setWorkTree(dir);
+ builder.setMustExist(true);
+ Repository repo2 = builder.build();
- assertEquals(repo1.getDirectory().getAbsolutePath(), repo2
- .getDirectory().getAbsolutePath());
- assertEquals(dir, repo2.getWorkTree());
- }
+ assertEquals(repo1.getDirectory().getAbsolutePath(),
+ repo2.getDirectory().getAbsolutePath());
+ assertEquals(dir, repo2.getWorkTree());
}
@Test
@@ -145,19 +145,18 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase {
File dotGit = new File(dir, Constants.DOT_GIT);
try (BufferedWriter writer = Files.newBufferedWriter(dotGit.toPath(),
UTF_8)) {
- writer.append("gitdir: ../" + Constants.DOT_GIT).close();
-
- FileRepositoryBuilder builder = new FileRepositoryBuilder();
- builder.setWorkTree(dir);
- builder.setMustExist(true);
- Repository repo2 = builder.build();
-
- // The tmp directory may be a symlink so the actual path
- // may not
- assertEquals(repo1.getDirectory().getCanonicalPath(), repo2
- .getDirectory().getCanonicalPath());
- assertEquals(dir, repo2.getWorkTree());
+ writer.append("gitdir: ../" + Constants.DOT_GIT);
}
+ FileRepositoryBuilder builder = new FileRepositoryBuilder();
+ builder.setWorkTree(dir);
+ builder.setMustExist(true);
+ Repository repo2 = builder.build();
+
+ // The tmp directory may be a symlink so the actual path
+ // may not
+ assertEquals(repo1.getDirectory().getCanonicalPath(),
+ repo2.getDirectory().getCanonicalPath());
+ assertEquals(dir, repo2.getWorkTree());
}
@Test
@@ -168,20 +167,20 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase {
try (BufferedWriter writer = Files.newBufferedWriter(dotGit.toPath(),
UTF_8)) {
writer.append(
- "gitdir: " + repo1.getDirectory().getAbsolutePath()).close();
- FileRepositoryBuilder builder = new FileRepositoryBuilder();
-
- builder.setWorkTree(dir);
- builder.findGitDir(dir);
- assertEquals(repo1.getDirectory().getAbsolutePath(), builder
- .getGitDir().getAbsolutePath());
- builder.setMustExist(true);
- Repository repo2 = builder.build();
-
- // The tmp directory may be a symlink
- assertEquals(repo1.getDirectory().getCanonicalPath(), repo2
- .getDirectory().getCanonicalPath());
- assertEquals(dir, repo2.getWorkTree());
+ "gitdir: " + repo1.getDirectory().getAbsolutePath());
}
+ FileRepositoryBuilder builder = new FileRepositoryBuilder();
+
+ builder.setWorkTree(dir);
+ builder.findGitDir(dir);
+ assertEquals(repo1.getDirectory().getAbsolutePath(),
+ builder.getGitDir().getAbsolutePath());
+ builder.setMustExist(true);
+ Repository repo2 = builder.build();
+
+ // The tmp directory may be a symlink
+ assertEquals(repo1.getDirectory().getCanonicalPath(),
+ repo2.getDirectory().getCanonicalPath());
+ assertEquals(dir, repo2.getWorkTree());
}
}