Skip to content

Commit f3b4f67

Browse files
author
Gary Gregory
committed
Add NullReader.INSTANCE.
1 parent f0fba1b commit f3b4f67

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/changes/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ The <action> type attribute can be add,update,fix,remove.
9999
<action dev="ggregory" type="add" due-to="Gary Gregory">
100100
Add NullInputStream.INSTANCE.
101101
</action>
102+
<action dev="ggregory" type="add" due-to="Gary Gregory">
103+
Add NullReader.INSTANCE.
104+
</action>
102105
<!-- UPDATE -->
103106
<action dev="ggregory" type="update" due-to="Dependabot">
104107
Bump Maven Javadoc plugin from 3.2.0 to 3.3.0.

src/main/java/org/apache/commons/io/input/NullReader.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@
6666
*/
6767
public class NullReader extends Reader {
6868

69+
/**
70+
* The singleton instance.
71+
*
72+
* @since 2.12.0
73+
*/
74+
public static final NullReader INSTANCE = new NullReader();
75+
6976
private final long size;
7077
private long position;
7178
private long mark = -1;

src/test/java/org/apache/commons/io/test/ThrowOnCloseReader.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ public class ThrowOnCloseReader extends ProxyReader {
3030
/**
3131
* Default ctor.
3232
*/
33-
@SuppressWarnings("resource")
3433
public ThrowOnCloseReader() {
35-
super(new NullReader());
34+
super(NullReader.INSTANCE);
3635
}
3736

3837
/**

0 commit comments

Comments
 (0)