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 0ca143f  Add ClosedOutputStream.INSTANCE and deprecate 
CLOSED_OUTPUT_STREAM.
0ca143f is described below

commit 0ca143f845441880dd7e3f3c87671512373cf6c6
Author: Gary Gregory <[email protected]>
AuthorDate: Mon Jul 12 14:41:20 2021 -0400

    Add ClosedOutputStream.INSTANCE and deprecate CLOSED_OUTPUT_STREAM.
---
 src/changes/changes.xml                                    |  3 +++
 .../apache/commons/io/output/CloseShieldOutputStream.java  |  2 +-
 .../org/apache/commons/io/output/ClosedOutputStream.java   | 14 ++++++++++++--
 .../apache/commons/io/output/TaggedOutputStreamTest.java   |  2 +-
 4 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 3e66e25..640a553 100644
--- a/src/changes/changes.xml
+++ b/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.
diff --git 
a/src/main/java/org/apache/commons/io/output/CloseShieldOutputStream.java 
b/src/main/java/org/apache/commons/io/output/CloseShieldOutputStream.java
index 1608890..a5c5485 100644
--- a/src/main/java/org/apache/commons/io/output/CloseShieldOutputStream.java
+++ b/src/main/java/org/apache/commons/io/output/CloseShieldOutputStream.java
@@ -61,7 +61,7 @@ public class CloseShieldOutputStream extends 
ProxyOutputStream {
      */
     @Override
     public void close() {
-        out = ClosedOutputStream.CLOSED_OUTPUT_STREAM;
+        out = ClosedOutputStream.INSTANCE;
     }
 
 }
diff --git a/src/main/java/org/apache/commons/io/output/ClosedOutputStream.java 
b/src/main/java/org/apache/commons/io/output/ClosedOutputStream.java
index cc77d9d..a6dcd39 100644
--- a/src/main/java/org/apache/commons/io/output/ClosedOutputStream.java
+++ b/src/main/java/org/apache/commons/io/output/ClosedOutputStream.java
@@ -31,9 +31,19 @@ import java.io.OutputStream;
 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.
diff --git 
a/src/test/java/org/apache/commons/io/output/TaggedOutputStreamTest.java 
b/src/test/java/org/apache/commons/io/output/TaggedOutputStreamTest.java
index 2212b8f..3c4e858 100644
--- a/src/test/java/org/apache/commons/io/output/TaggedOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/output/TaggedOutputStreamTest.java
@@ -103,7 +103,7 @@ public class TaggedOutputStreamTest  {
     @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())));

Reply via email to