Use try-with-resources, avoids compiler warnings.
@@ -299,13 +299,14 @@ public void write(final int b) throws IOException {
}
@Test
- public void testAsWriterAppendable() {
+ public void testAsWriterAppendable() throws IOException {
final Appendable a = new StringBuffer();
- final Writer w = IOUtils.writer(a);
+ try (final Writer w = IOUtils.writer(a)) {
assertNotSame(w, a);
assertEquals(AppendableWriter.class, w.getClass());
assertSame(w, IOUtils.writer(w));
}
+ }
@Test
public void testAsWriterNull() {
@@ -313,13 +314,14 @@ public void testAsWriterNull() {
}
@Test
- public void testAsWriterStringBuilder() {
+ public void testAsWriterStringBuilder() throws IOException {
final Appendable a = new StringBuilder();
- final Writer w = IOUtils.writer(a);
+ try (final Writer w = IOUtils.writer(a)) {
assertNotSame(w, a);
assertEquals(StringBuilderWriter.class, w.getClass());
assertSame(w, IOUtils.writer(w));
}
+ }
/**
* IO-764 IOUtils.write() throws NegativeArraySizeException while writing big strings.
