This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git
The following commit(s) were added to refs/heads/master by this push:
new dc9c6749 Use try-with-resources, avoids compiler warnings.
dc9c6749 is described below
commit dc9c6749d2322f4233bd79b6ad45d3085a5bfca9
Author: Gary Gregory <[email protected]>
AuthorDate: Mon Apr 4 09:04:23 2022 -0400
Use try-with-resources, avoids compiler warnings.
---
.../java/org/apache/commons/io/IOUtilsTest.java | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/src/test/java/org/apache/commons/io/IOUtilsTest.java
b/src/test/java/org/apache/commons/io/IOUtilsTest.java
index 0dc429f6..3f2df86e 100644
--- a/src/test/java/org/apache/commons/io/IOUtilsTest.java
+++ b/src/test/java/org/apache/commons/io/IOUtilsTest.java
@@ -299,12 +299,13 @@ public class IOUtilsTest {
}
@Test
- public void testAsWriterAppendable() {
+ public void testAsWriterAppendable() throws IOException {
final Appendable a = new StringBuffer();
- final Writer w = IOUtils.writer(a);
- assertNotSame(w, a);
- assertEquals(AppendableWriter.class, w.getClass());
- assertSame(w, IOUtils.writer(w));
+ try (final Writer w = IOUtils.writer(a)) {
+ assertNotSame(w, a);
+ assertEquals(AppendableWriter.class, w.getClass());
+ assertSame(w, IOUtils.writer(w));
+ }
}
@Test
@@ -313,12 +314,13 @@ public class IOUtilsTest {
}
@Test
- public void testAsWriterStringBuilder() {
+ public void testAsWriterStringBuilder() throws IOException {
final Appendable a = new StringBuilder();
- final Writer w = IOUtils.writer(a);
- assertNotSame(w, a);
- assertEquals(StringBuilderWriter.class, w.getClass());
- assertSame(w, IOUtils.writer(w));
+ try (final Writer w = IOUtils.writer(a)) {
+ assertNotSame(w, a);
+ assertEquals(StringBuilderWriter.class, w.getClass());
+ assertSame(w, IOUtils.writer(w));
+ }
}
/**