MarkShieldInputStream#reset should throw
UnsupportedOperationException.
MODIFY
src/changes/changes.xml
src/changes/changes.xml
@@ -102,6 +102,9 @@ The <action> type attribute can be add,update,fix,remove.
<action issue="IO-690" dev="ggregory" type="fix" due-to="Chris Heisterkamp, Gary Gregory">
IOUtils.toByteArray(null) no longer throws a NullPointerException.
</action>
+ <action issue="IO-705" dev="ggregory" type="fix" due-to="Hao Zhong, Gary Gregory">
+ MarkShieldInputStream#reset should throw UnsupportedOperationException.
+ </action>
<!-- ADD -->
<action dev="ggregory" type="add" due-to="Gary Gregory">
Add FileSystemProviders class.

MODIFY
src/main/java/org/apache/commons/io/input/MarkShieldInputStream.java
src/main/java/org/apache/commons/io/input/MarkShieldInputStream.java
@@ -59,6 +59,6 @@ public boolean markSupported() {
@SuppressWarnings("sync-override")
@Override
public void reset() throws IOException {
- throw new IOException("mark/reset not supported");
+ throw UnsupportedOperationExceptions.reset();
}
}

MODIFY
src/main/java/org/apache/commons/io/input/UnsupportedOperationExceptions.java
src/main/java/org/apache/commons/io/input/UnsupportedOperationExceptions.java
/**
* Package-private factory for {@link UnsupportedOperationException} to provide messages with consistent formatting.
*
- * TODO Consider making this public and use from LineIterator.
+ * TODO Consider making this public and use from LineIterator but this feels like it belongs in LANG rather than IO.
*/
class UnsupportedOperationExceptions {

MODIFY
src/test/java/org/apache/commons/io/input/MarkShieldInputStreamTest.java
src/test/java/org/apache/commons/io/input/MarkShieldInputStreamTest.java
@@ -78,7 +78,7 @@ public void resetThrowsExceptionWhenUnderylingDoesNotSupport() throws IOExceptio
// test wrapping an underlying stream which does NOT support marking
try (final MarkShieldInputStream msis = new MarkShieldInputStream(
new NullInputStream(64, false, false))) {
- assertThrows(IOException.class, () -> msis.reset());
+ assertThrows(UnsupportedOperationException.class, () -> msis.reset());
}
}
@@ -87,7 +87,7 @@ public void resetThrowsExceptionWhenUnderylingSupports() throws IOException {
// test wrapping an underlying stream which supports marking
try (final MarkShieldInputStream msis = new MarkShieldInputStream(
new NullInputStream(64, true, false))) {
- assertThrows(IOException.class, () -> msis.reset());
+ assertThrows(UnsupportedOperationException.class, () -> msis.reset());
}
}

[IO-705] MarkShieldInputStream#reset should throw
UnsupportedOperationException.