Add NullWriter.INSTANCE and deprecate NULL_WRITER.
MODIFY
src/changes/changes.xml
src/changes/changes.xml
@@ -93,6 +93,9 @@ The <action> type attribute can be add,update,fix,remove.
<action dev="ggregory" type="add" due-to="Gary Gregory">
Add NullPrintStream.INSTANCE and deprecate NULL_PRINT_STREAM.
</action>
+ <action dev="ggregory" type="add" due-to="Gary Gregory">
+ Add NullWriter.INSTANCE and deprecate NULL_WRITER.
+ </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/NullWriter.java
src/main/java/org/apache/commons/io/output/NullWriter.java
public class NullWriter extends Writer {
/**
- * A singleton.
+ * The singleton instance.
+ *
+ * @since 2.12.0
+ */
+ public static final NullWriter INSTANCE = new NullWriter();
+
+ /**
+ * The singleton instance.
+ *
+ * @deprecated Use {@link #INSTANCE}.
*/
- public static final NullWriter NULL_WRITER = new NullWriter();
+ @Deprecated
+ public static final NullWriter NULL_WRITER = INSTANCE;
/**
* Constructs a new NullWriter.

MODIFY
src/test/java/org/apache/commons/io/output/NullWriterTest.java
src/test/java/org/apache/commons/io/output/NullWriterTest.java
@Test
public void testNull() {
final char[] chars = { 'A', 'B', 'C' };
- try (final NullWriter writer = NullWriter.NULL_WRITER) {
+ try (final NullWriter writer = NullWriter.INSTANCE) {
writer.write(1);
writer.write(chars);
writer.write(chars, 1, 1);

MODIFY
src/test/java/org/apache/commons/io/output/ProxyWriterTest.java
src/test/java/org/apache/commons/io/output/ProxyWriterTest.java
@@ -107,7 +107,7 @@ public void writeCharArrayPartial() throws Exception {
@Test
public void nullString() throws Exception {
- try (final ProxyWriter proxy = new ProxyWriter(NullWriter.NULL_WRITER)) {
+ try (final ProxyWriter proxy = new ProxyWriter(NullWriter.INSTANCE)) {
proxy.write((String) null);
proxy.write((String) null, 0, 0);
}
@@ -115,7 +115,7 @@ public void nullString() throws Exception {
@Test
public void nullCharArray() throws Exception {
- try (final ProxyWriter proxy = new ProxyWriter(NullWriter.NULL_WRITER)) {
+ try (final ProxyWriter proxy = new ProxyWriter(NullWriter.INSTANCE)) {
proxy.write((char[]) null);
proxy.write((char[]) null, 0, 0);
}
@@ -123,7 +123,7 @@ public void nullCharArray() throws Exception {
@Test
public void nullCharSequence() throws Exception {
- try (final ProxyWriter proxy = new ProxyWriter(NullWriter.NULL_WRITER)) {
+ try (final ProxyWriter proxy = new ProxyWriter(NullWriter.INSTANCE)) {
proxy.append(null);
}
}

MODIFY
src/test/java/org/apache/commons/io/test/ThrowOnCloseWriter.java
src/test/java/org/apache/commons/io/test/ThrowOnCloseWriter.java
* Default ctor.
*/
public ThrowOnCloseWriter() {
- super(NullWriter.NULL_WRITER);
+ super(NullWriter.INSTANCE);
}
/**

Add NullWriter.INSTANCE and deprecate NULL_WRITER.