Skip to content

Commit b4d80a8

Browse files
author
Gary Gregory
committed
[IO-705] MarkShieldInputStream#reset should throw
UnsupportedOperationException.
1 parent f7b8863 commit b4d80a8

4 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/changes/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ The <action> type attribute can be add,update,fix,remove.
102102
<action issue="IO-690" dev="ggregory" type="fix" due-to="Chris Heisterkamp, Gary Gregory">
103103
IOUtils.toByteArray(null) no longer throws a NullPointerException.
104104
</action>
105+
<action issue="IO-705" dev="ggregory" type="fix" due-to="Hao Zhong, Gary Gregory">
106+
MarkShieldInputStream#reset should throw UnsupportedOperationException.
107+
</action>
105108
<!-- ADD -->
106109
<action dev="ggregory" type="add" due-to="Gary Gregory">
107110
Add FileSystemProviders class.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ public boolean markSupported() {
5959
@SuppressWarnings("sync-override")
6060
@Override
6161
public void reset() throws IOException {
62-
throw new IOException("mark/reset not supported");
62+
throw UnsupportedOperationExceptions.reset();
6363
}
6464
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/**
2121
* Package-private factory for {@link UnsupportedOperationException} to provide messages with consistent formatting.
2222
*
23-
* TODO Consider making this public and use from LineIterator.
23+
* TODO Consider making this public and use from LineIterator but this feels like it belongs in LANG rather than IO.
2424
*/
2525
class UnsupportedOperationExceptions {
2626

src/test/java/org/apache/commons/io/input/MarkShieldInputStreamTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void resetThrowsExceptionWhenUnderylingDoesNotSupport() throws IOExceptio
7878
// test wrapping an underlying stream which does NOT support marking
7979
try (final MarkShieldInputStream msis = new MarkShieldInputStream(
8080
new NullInputStream(64, false, false))) {
81-
assertThrows(IOException.class, () -> msis.reset());
81+
assertThrows(UnsupportedOperationException.class, () -> msis.reset());
8282
}
8383
}
8484

@@ -87,7 +87,7 @@ public void resetThrowsExceptionWhenUnderylingSupports() throws IOException {
8787
// test wrapping an underlying stream which supports marking
8888
try (final MarkShieldInputStream msis = new MarkShieldInputStream(
8989
new NullInputStream(64, true, false))) {
90-
assertThrows(IOException.class, () -> msis.reset());
90+
assertThrows(UnsupportedOperationException.class, () -> msis.reset());
9191
}
9292
}
9393

0 commit comments

Comments
 (0)