summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.lfs.test/tst/org
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2018-03-07 14:42:47 +0900
committerDavid Pursehouse <david.pursehouse@gmail.com>2018-03-07 14:42:47 +0900
commit658c7c179d8718214f047886787ac27889e4331d (patch)
tree471bf43ff9d8797fdede14c24744ee1e9194d00e /org.eclipse.jgit.lfs.test/tst/org
parentee4dd50b3f5caa0536d2635df80ad4067d2cf4c9 (diff)
downloadjgit-658c7c179d8718214f047886787ac27889e4331d.tar.gz
jgit-658c7c179d8718214f047886787ac27889e4331d.zip
LongObjectIdTest: Open OutputStreamWriter in try-with-resource
Change-Id: Ic7c2109204f94c70b933191b46d4a8f2c16a1533 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.lfs.test/tst/org')
-rw-r--r--org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LongObjectIdTest.java16
1 files changed, 9 insertions, 7 deletions
diff --git a/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LongObjectIdTest.java b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LongObjectIdTest.java
index d6dd3aa607..8642e7eb3b 100644
--- a/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LongObjectIdTest.java
+++ b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LongObjectIdTest.java
@@ -392,9 +392,10 @@ public class LongObjectIdTest {
public void testCopyToWriter() throws IOException {
AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test");
ByteArrayOutputStream os = new ByteArrayOutputStream(64);
- OutputStreamWriter w = new OutputStreamWriter(os, Constants.CHARSET);
- id1.copyTo(w);
- w.close();
+ try (OutputStreamWriter w = new OutputStreamWriter(os,
+ Constants.CHARSET)) {
+ id1.copyTo(w);
+ }
assertEquals(id1, LongObjectId.fromString(os.toByteArray(), 0));
}
@@ -402,10 +403,11 @@ public class LongObjectIdTest {
public void testCopyToWriterWithBuf() throws IOException {
AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test");
ByteArrayOutputStream os = new ByteArrayOutputStream(64);
- OutputStreamWriter w = new OutputStreamWriter(os, Constants.CHARSET);
- char[] buf = new char[64];
- id1.copyTo(buf, w);
- w.close();
+ try (OutputStreamWriter w = new OutputStreamWriter(os,
+ Constants.CHARSET)) {
+ char[] buf = new char[64];
+ id1.copyTo(buf, w);
+ }
assertEquals(id1, LongObjectId.fromString(os.toByteArray(), 0));
}