Resue org.apache.commons.io.input.ClosedInputStream.CLOSED_INPUT_STREAM.
MODIFY
src/main/java/org/apache/commons/io/input/AutoCloseInputStream.java
src/main/java/org/apache/commons/io/input/AutoCloseInputStream.java
@@ -62,7 +62,7 @@ public AutoCloseInputStream(final InputStream in) {
@Override
public void close() throws IOException {
in.close();
- in = new ClosedInputStream();
+ in = ClosedInputStream.CLOSED_INPUT_STREAM;
}
/**

MODIFY
src/main/java/org/apache/commons/io/output/AbstractByteArrayOutputStream.java
src/main/java/org/apache/commons/io/output/AbstractByteArrayOutputStream.java
@@ -307,7 +307,7 @@ protected void writeToImpl(final OutputStream out) throws IOException {
final InputStreamConstructor<T> isConstructor) {
int remaining = count;
if (remaining == 0) {
- return new ClosedInputStream();
+ return ClosedInputStream.CLOSED_INPUT_STREAM;
}
final List<T> list = new ArrayList<>(buffers.size());
for (final byte[] buf : buffers) {

MODIFY
src/test/java/org/apache/commons/io/input/TaggedInputStreamTest.java
src/test/java/org/apache/commons/io/input/TaggedInputStreamTest.java
@Test
public void testEmptyStream() throws IOException {
- final InputStream stream = new TaggedInputStream(new ClosedInputStream());
+ final InputStream stream = new TaggedInputStream(ClosedInputStream.CLOSED_INPUT_STREAM);
assertEquals(0, stream.available());
assertEquals(-1, stream.read());
assertEquals(-1, stream.read(new byte[1]));
@@ -111,8 +111,7 @@ public void testBrokenStream() {
@Test
public void testOtherException() throws Exception {
final IOException exception = new IOException("test exception");
- final InputStream closed = new ClosedInputStream();
- final TaggedInputStream stream = new TaggedInputStream(closed);
+ final TaggedInputStream stream = new TaggedInputStream(ClosedInputStream.CLOSED_INPUT_STREAM);
assertFalse(stream.isCauseOf(exception));
assertFalse(stream.isCauseOf(

Resue org.apache.commons.io.input.ClosedInputStream.CLOSED_INPUT_STREAM.