Add BrokenInputStream.INSTANCE.
MODIFY
src/changes/changes.xml
src/changes/changes.xml
@@ -69,6 +69,9 @@ The <action> type attribute can be add,update,fix,remove.
<action dev="ggregory" type="add" due-to="Gary Gregory">
Add UncheckedFilterInputStream.
</action>
+ <action dev="ggregory" type="add" due-to="Gary Gregory">
+ Add BrokenInputStream.INSTANCE.
+ </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/input/BrokenInputStream.java
src/main/java/org/apache/commons/io/input/BrokenInputStream.java
*/
public class BrokenInputStream extends InputStream {
+ /**
+ * The singleton instance.
+ *
+ * @since 2.12.0
+ */
+ public static final BrokenInputStream INSTANCE = new BrokenInputStream();
+
/**
* The exception that is thrown by all methods of this class.
*/

MODIFY
src/test/java/org/apache/commons/io/input/ObservableInputStreamTest.java
src/test/java/org/apache/commons/io/input/ObservableInputStreamTest.java
@@ -129,21 +129,21 @@ public long getFinishedCount() {
@Test
public void testBrokenInputStreamRead() throws IOException {
- try (final ObservableInputStream ois = new ObservableInputStream(new BrokenInputStream())) {
+ try (final ObservableInputStream ois = new ObservableInputStream(BrokenInputStream.INSTANCE)) {
assertThrows(IOException.class, () -> ois.read());
}
}
@Test
public void testBrokenInputStreamReadBuffer() throws IOException {
- try (final ObservableInputStream ois = new ObservableInputStream(new BrokenInputStream())) {
+ try (final ObservableInputStream ois = new ObservableInputStream(BrokenInputStream.INSTANCE)) {
assertThrows(IOException.class, () -> ois.read(new byte[1]));
}
}
@Test
public void testBrokenInputStreamReadSubBuffer() throws IOException {
- try (final ObservableInputStream ois = new ObservableInputStream(new BrokenInputStream())) {
+ try (final ObservableInputStream ois = new ObservableInputStream(BrokenInputStream.INSTANCE)) {
assertThrows(IOException.class, () -> ois.read(new byte[2], 0, 1));
}
}

Add BrokenInputStream.INSTANCE.