Skip to content

Commit 0ca143f

Browse files
author
Gary Gregory
committed
Add ClosedOutputStream.INSTANCE and deprecate CLOSED_OUTPUT_STREAM.
1 parent bf17c07 commit 0ca143f

4 files changed

Lines changed: 17 additions & 4 deletions

File tree

src/changes/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ The <action> type attribute can be add,update,fix,remove.
8181
<action dev="ggregory" type="add" due-to="Gary Gregory">
8282
Add BrokenWriter.INSTANCE.
8383
</action>
84+
<action dev="ggregory" type="add" due-to="Gary Gregory">
85+
Add ClosedOutputStream.INSTANCE and deprecate CLOSED_OUTPUT_STREAM.
86+
</action>
8487
<!-- UPDATE -->
8588
<action dev="ggregory" type="update" due-to="Dependabot">
8689
Bump Maven Javadoc plugin from 3.2.0 to 3.3.0.

src/main/java/org/apache/commons/io/output/CloseShieldOutputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public CloseShieldOutputStream(final OutputStream outputStream) {
6161
*/
6262
@Override
6363
public void close() {
64-
out = ClosedOutputStream.CLOSED_OUTPUT_STREAM;
64+
out = ClosedOutputStream.INSTANCE;
6565
}
6666

6767
}

src/main/java/org/apache/commons/io/output/ClosedOutputStream.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,19 @@
3131
public class ClosedOutputStream extends OutputStream {
3232

3333
/**
34-
* A singleton.
34+
* The singleton instance.
35+
*
36+
* @since 2.12.0
37+
*/
38+
public static final ClosedOutputStream INSTANCE = new ClosedOutputStream();
39+
40+
/**
41+
* The singleton instance.
42+
*
43+
* @deprecated Use {@link #INSTANCE}.
3544
*/
36-
public static final ClosedOutputStream CLOSED_OUTPUT_STREAM = new ClosedOutputStream();
45+
@Deprecated
46+
public static final ClosedOutputStream CLOSED_OUTPUT_STREAM = INSTANCE;
3747

3848
/**
3949
* Throws an {@link IOException} to indicate that the stream is closed.

src/test/java/org/apache/commons/io/output/TaggedOutputStreamTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public void testBrokenStream() {
103103
@Test
104104
public void testOtherException() throws Exception {
105105
final IOException exception = new IOException("test exception");
106-
try (final TaggedOutputStream stream = new TaggedOutputStream(ClosedOutputStream.CLOSED_OUTPUT_STREAM)) {
106+
try (final TaggedOutputStream stream = new TaggedOutputStream(ClosedOutputStream.INSTANCE)) {
107107

108108
assertFalse(stream.isCauseOf(exception));
109109
assertFalse(stream.isCauseOf(new TaggedIOException(exception, UUID.randomUUID())));

0 commit comments

Comments
 (0)