Add ClosedOutputStream.INSTANCE and deprecate CLOSED_OUTPUT_STREAM.
MODIFY
src/changes/changes.xml
src/changes/changes.xml
@@ -81,6 +81,9 @@ The <action> type attribute can be add,update,fix,remove.
<action dev="ggregory" type="add" due-to="Gary Gregory">
Add BrokenWriter.INSTANCE.
</action>
+ <action dev="ggregory" type="add" due-to="Gary Gregory">
+ Add ClosedOutputStream.INSTANCE and deprecate CLOSED_OUTPUT_STREAM.
+ </action>
<!-- UPDATE -->
<action dev="ggregory" type="update" due-to="Dependabot">
Bump Maven Javadoc plugin from 3.2.0 to 3.3.0.

MODIFY
src/main/java/org/apache/commons/io/output/CloseShieldOutputStream.java
src/main/java/org/apache/commons/io/output/CloseShieldOutputStream.java
@@ -61,7 +61,7 @@ public CloseShieldOutputStream(final OutputStream outputStream) {
*/
@Override
public void close() {
- out = ClosedOutputStream.CLOSED_OUTPUT_STREAM;
+ out = ClosedOutputStream.INSTANCE;
}
}

MODIFY
src/main/java/org/apache/commons/io/output/ClosedOutputStream.java
src/main/java/org/apache/commons/io/output/ClosedOutputStream.java
public class ClosedOutputStream extends OutputStream {
/**
- * A singleton.
+ * The singleton instance.
+ *
+ * @since 2.12.0
+ */
+ public static final ClosedOutputStream INSTANCE = new ClosedOutputStream();
+
+ /**
+ * The singleton instance.
+ *
+ * @deprecated Use {@link #INSTANCE}.
*/
- public static final ClosedOutputStream CLOSED_OUTPUT_STREAM = new ClosedOutputStream();
+ @Deprecated
+ public static final ClosedOutputStream CLOSED_OUTPUT_STREAM = INSTANCE;
/**
* Throws an {@link IOException} to indicate that the stream is closed.

MODIFY
src/test/java/org/apache/commons/io/output/TaggedOutputStreamTest.java
src/test/java/org/apache/commons/io/output/TaggedOutputStreamTest.java
@@ -103,7 +103,7 @@ public void testBrokenStream() {
@Test
public void testOtherException() throws Exception {
final IOException exception = new IOException("test exception");
- try (final TaggedOutputStream stream = new TaggedOutputStream(ClosedOutputStream.CLOSED_OUTPUT_STREAM)) {
+ try (final TaggedOutputStream stream = new TaggedOutputStream(ClosedOutputStream.INSTANCE)) {
assertFalse(stream.isCauseOf(exception));
assertFalse(stream.isCauseOf(new TaggedIOException(exception, UUID.randomUUID())));

Add ClosedOutputStream.INSTANCE and deprecate CLOSED_OUTPUT_STREAM.