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
commit e8f50acf5d9ca5f2b4a1350c6c26bc1afe2cf590 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sat Jul 10 11:09:29 2021 -0400 Add BrokenReader.INSTANCE. --- src/changes/changes.xml | 6 ++++++ .../java/org/apache/commons/io/input/BrokenReader.java | 17 +++++++++++------ .../org/apache/commons/io/input/BrokenReaderTest.java | 6 ++++++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index b231417..27499cb 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -45,6 +45,12 @@ The <action> type attribute can be add,update,fix,remove. </properties> <body> + <release version="2.13.0" date="2021-MM-DD" description="Java 8 required."> + <!-- ADD --> + <action dev="ggregory" type="add" due-to="Gary Gregory"> + Add BrokenReader.INSTANCE. + </action> + </release> <release version="2.11.0" date="2021-07-09" description="Java 8 required."> <!-- FIX --> <action issue="IO-741" dev="ggregory" type="fix" due-to="Zach Sherman"> diff --git a/src/main/java/org/apache/commons/io/input/BrokenReader.java b/src/main/java/org/apache/commons/io/input/BrokenReader.java index 6fcc9df..1603778 100644 --- a/src/main/java/org/apache/commons/io/input/BrokenReader.java +++ b/src/main/java/org/apache/commons/io/input/BrokenReader.java @@ -20,11 +20,9 @@ import java.io.IOException; import java.io.Reader; /** - * Broken reader. This reader always throws an {@link IOException} from - * all the {@link Reader} methods where the exception is declared. + * Broken reader. This reader always throws an {@link IOException} from all the {@link Reader} methods where the exception is declared. * <p> - * This class is mostly useful for testing error handling in code that uses a - * reader. + * This class is mostly useful for testing error handling in code that uses a reader. * </p> * * @since 2.7 @@ -32,6 +30,13 @@ import java.io.Reader; public class BrokenReader extends Reader { /** + * A singleton instance using a default IOException. + * + * @since 2.12.0 + */ + public static final BrokenReader INSTANCE = new BrokenReader(); + + /** * The exception that is thrown by all methods of this class. */ private final IOException exception; @@ -77,8 +82,8 @@ public class BrokenReader extends Reader { * Throws the configured exception. * * @param cbuf ignored - * @param off ignored - * @param len ignored + * @param off ignored + * @param len ignored * @return nothing * @throws IOException always thrown */ diff --git a/src/test/java/org/apache/commons/io/input/BrokenReaderTest.java b/src/test/java/org/apache/commons/io/input/BrokenReaderTest.java index 5844ca2..56e9b3e 100644 --- a/src/test/java/org/apache/commons/io/input/BrokenReaderTest.java +++ b/src/test/java/org/apache/commons/io/input/BrokenReaderTest.java @@ -17,6 +17,7 @@ package org.apache.commons.io.input; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; @@ -52,6 +53,11 @@ public class BrokenReaderTest { } @Test + public void testInstance() { + assertNotNull(BrokenReader.INSTANCE); + } + + @Test public void testMark() { try { reader.mark(1);