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
commit a467b03e1b481a288ad9271aca2942d4504dba7f Author: Gary Gregory <gardgreg...@gmail.com> AuthorDate: Mon May 27 08:17:52 2019 -0400 Minor clean ups. --- .../apache/commons/io/output/NullOutputStream.java | 10 ++++--- .../commons/io/output/NullOutputStreamTest.java | 34 +++++++++++++--------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/apache/commons/io/output/NullOutputStream.java b/src/main/java/org/apache/commons/io/output/NullOutputStream.java index 8d05129..def39ba 100644 --- a/src/main/java/org/apache/commons/io/output/NullOutputStream.java +++ b/src/main/java/org/apache/commons/io/output/NullOutputStream.java @@ -25,7 +25,6 @@ import java.io.OutputStream; * This output stream has no destination (file/socket etc.) and all * bytes written to it are ignored and lost. * </p> - * */ public class NullOutputStream extends OutputStream { @@ -36,32 +35,35 @@ public class NullOutputStream extends OutputStream { /** * Does nothing - output to <code>/dev/null</code>. + * * @param b The bytes to write * @param off The start offset * @param len The number of bytes to write */ @Override public void write(final byte[] b, final int off, final int len) { - //to /dev/null + // To /dev/null } /** * Does nothing - output to <code>/dev/null</code>. + * * @param b The byte to write */ @Override public void write(final int b) { - //to /dev/null + // To /dev/null } /** * Does nothing - output to <code>/dev/null</code>. + * * @param b The bytes to write * @throws IOException never */ @Override public void write(final byte[] b) throws IOException { - //to /dev/null + // To /dev/null } } diff --git a/src/test/java/org/apache/commons/io/output/NullOutputStreamTest.java b/src/test/java/org/apache/commons/io/output/NullOutputStreamTest.java index c5a6bc2..6b3edcc 100644 --- a/src/test/java/org/apache/commons/io/output/NullOutputStreamTest.java +++ b/src/test/java/org/apache/commons/io/output/NullOutputStreamTest.java @@ -23,24 +23,32 @@ import org.junit.Test; /** - * Really not a lot to do here, but checking that no - * Exceptions are thrown. - * + * Really not a lot to do here, but checking that no Exceptions are thrown. */ - public class NullOutputStreamTest { + private void process(final NullOutputStream nos) throws IOException { + nos.write("string".getBytes()); + nos.write("some string".getBytes(), 3, 5); + nos.write(1); + nos.write(0x0f); + nos.flush(); + nos.close(); + nos.write("allowed".getBytes()); + nos.write(255); + } + @Test - public void testNull() throws IOException { + public void testNewInstance() throws IOException { try (final NullOutputStream nos = new NullOutputStream()) { - nos.write("string".getBytes()); - nos.write("some string".getBytes(), 3, 5); - nos.write(1); - nos.write(0x0f); - nos.flush(); - nos.close(); - nos.write("allowed".getBytes()); - nos.write(255); + process(nos); + } + } + + @Test + public void testSingleton() throws IOException { + try (final NullOutputStream nos = NullOutputStream.NULL_OUTPUT_STREAM) { + process(nos); } }