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 fbc646f Add NullWriter.INSTANCE and deprecate NULL_WRITER.
fbc646f is described below
commit fbc646fda1cc0dc4c81d172e0679ea91f5881c9c
Author: Gary Gregory <[email protected]>
AuthorDate: Mon Jul 12 14:55:03 2021 -0400
Add NullWriter.INSTANCE and deprecate NULL_WRITER.
---
src/changes/changes.xml | 3 +++
src/main/java/org/apache/commons/io/output/NullWriter.java | 14 ++++++++++++--
.../java/org/apache/commons/io/output/NullWriterTest.java | 2 +-
.../java/org/apache/commons/io/output/ProxyWriterTest.java | 6 +++---
.../org/apache/commons/io/test/ThrowOnCloseWriter.java | 2 +-
5 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index b597e4d..551e10f 100644
--- a/src/changes/changes.xml
+++ b/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.
diff --git a/src/main/java/org/apache/commons/io/output/NullWriter.java
b/src/main/java/org/apache/commons/io/output/NullWriter.java
index 4c6f405..7f5263a 100644
--- a/src/main/java/org/apache/commons/io/output/NullWriter.java
+++ b/src/main/java/org/apache/commons/io/output/NullWriter.java
@@ -27,9 +27,19 @@ import java.io.Writer;
public class NullWriter extends Writer {
/**
- * A singleton.
+ * The singleton instance.
+ *
+ * @since 2.12.0
*/
- public static final NullWriter NULL_WRITER = new NullWriter();
+ public static final NullWriter INSTANCE = new NullWriter();
+
+ /**
+ * The singleton instance.
+ *
+ * @deprecated Use {@link #INSTANCE}.
+ */
+ @Deprecated
+ public static final NullWriter NULL_WRITER = INSTANCE;
/**
* Constructs a new NullWriter.
diff --git a/src/test/java/org/apache/commons/io/output/NullWriterTest.java
b/src/test/java/org/apache/commons/io/output/NullWriterTest.java
index 404dfd8..b34fcc0 100644
--- a/src/test/java/org/apache/commons/io/output/NullWriterTest.java
+++ b/src/test/java/org/apache/commons/io/output/NullWriterTest.java
@@ -27,7 +27,7 @@ public class NullWriterTest {
@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);
diff --git a/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java
b/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java
index 531d00c..3487333 100644
--- a/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java
+++ b/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java
@@ -107,7 +107,7 @@ public class ProxyWriterTest {
@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 class ProxyWriterTest {
@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 class ProxyWriterTest {
@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);
}
}
diff --git a/src/test/java/org/apache/commons/io/test/ThrowOnCloseWriter.java
b/src/test/java/org/apache/commons/io/test/ThrowOnCloseWriter.java
index 6ec07ec..189a444 100644
--- a/src/test/java/org/apache/commons/io/test/ThrowOnCloseWriter.java
+++ b/src/test/java/org/apache/commons/io/test/ThrowOnCloseWriter.java
@@ -31,7 +31,7 @@ public class ThrowOnCloseWriter extends ProxyWriter {
* Default ctor.
*/
public ThrowOnCloseWriter() {
- super(NullWriter.NULL_WRITER);
+ super(NullWriter.INSTANCE);
}
/**