summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2018-03-06 08:22:48 +0900
committerDavid Pursehouse <david.pursehouse@gmail.com>2018-03-06 08:22:48 +0900
commitf8cd892b27e588cbdd601102a8189800b76aeda5 (patch)
tree728bdd220ec2f4576eefe96fdd3973aca6b845fa /org.eclipse.jgit.test
parent3fd6a3857b3aa16757fe6b09d94ef294555ffc8b (diff)
downloadjgit-f8cd892b27e588cbdd601102a8189800b76aeda5.tar.gz
jgit-f8cd892b27e588cbdd601102a8189800b76aeda5.zip
CommitAndLogCommandTest: Open PrintWriter in try-with-resource
Change-Id: I0c7f07e27d1881d8856dac008110fcaa85c98fbb 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/CommitAndLogCommandTest.java30
1 files changed, 15 insertions, 15 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTest.java
index 1d5c6742c7..ca0630ea35 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTest.java
@@ -120,9 +120,9 @@ public class CommitAndLogCommandTest extends RepositoryTestCase {
// create first file
File file = new File(db.getWorkTree(), "a.txt");
FileUtils.createNewFile(file);
- PrintWriter writer = new PrintWriter(file);
- writer.print("content1");
- writer.close();
+ try (PrintWriter writer = new PrintWriter(file)) {
+ writer.print("content1");
+ }
// First commit - a.txt file
git.add().addFilepattern("a.txt").call();
@@ -131,9 +131,9 @@ public class CommitAndLogCommandTest extends RepositoryTestCase {
// create second file
file = new File(db.getWorkTree(), "b.txt");
FileUtils.createNewFile(file);
- writer = new PrintWriter(file);
- writer.print("content2");
- writer.close();
+ try (PrintWriter writer = new PrintWriter(file)) {
+ writer.print("content2");
+ }
// Second commit - b.txt file
git.add().addFilepattern("b.txt").call();
@@ -231,9 +231,9 @@ public class CommitAndLogCommandTest extends RepositoryTestCase {
JGitInternalException, GitAPIException {
File file = new File(db.getWorkTree(), "a.txt");
FileUtils.createNewFile(file);
- PrintWriter writer = new PrintWriter(file);
- writer.print("content");
- writer.close();
+ try (PrintWriter writer = new PrintWriter(file)) {
+ writer.print("content");
+ }
try (Git git = new Git(db)) {
git.add().addFilepattern("a.txt").call();
@@ -242,9 +242,9 @@ public class CommitAndLogCommandTest extends RepositoryTestCase {
assertEquals("6b584e8ece562ebffc15d38808cd6b98fc3d97ea",
tw.getObjectId(0).getName());
- writer = new PrintWriter(file);
- writer.print("content2");
- writer.close();
+ try (PrintWriter writer = new PrintWriter(file)) {
+ writer.print("content2");
+ }
commit = git.commit().setMessage("second commit").call();
tw = TreeWalk.forPath(db, "a.txt", commit.getTree());
assertEquals("6b584e8ece562ebffc15d38808cd6b98fc3d97ea",
@@ -265,9 +265,9 @@ public class CommitAndLogCommandTest extends RepositoryTestCase {
// create file
File file = new File(db.getWorkTree(), "a.txt");
FileUtils.createNewFile(file);
- PrintWriter writer = new PrintWriter(file);
- writer.print("content1");
- writer.close();
+ try (PrintWriter writer = new PrintWriter(file)) {
+ writer.print("content1");
+ }
// First commit - a.txt file
git.add().addFilepattern("a.txt").call();