You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Hao Zhong (Jira)" <ji...@apache.org> on 2021/01/20 05:19:00 UTC
[jira] [Created] (IO-705) MarkShieldInputStream#reset is more
reasonable to throw UnsupportedOperationException
Hao Zhong created IO-705:
----------------------------
Summary: MarkShieldInputStream#reset is more reasonable to throw UnsupportedOperationException
Key: IO-705
URL: https://issues.apache.org/jira/browse/IO-705
Project: Commons IO
Issue Type: Bug
Reporter: Hao Zhong
The code of MarkShieldInputStream#reset is as follows:
{code:java}
public void reset() throws IOException {
throw new IOException("mark/reset not supported");
}
{code}
The message indicates that it is better to throw UnsupportedOperationException. Indeed, otehr classes throw that exception in similar contexts:
WindowsLineEndingInputStream#mark
{code:java}
public synchronized void mark(final int readlimit) {
throw new UnsupportedOperationException("Mark not supported");
}
{code}
NullReader#reset:
{code:java}
public synchronized void reset() throws IOException {
if (!markSupported) {
throw new UnsupportedOperationException("Mark not supported");
}
if (mark < 0) {
throw new IOException("No position has been marked");
}
if (position > mark + readlimit) {
throw new IOException("Marked position [" + mark +
"] is no longer valid - passed the read limit [" +
readlimit + "]");
}
position = mark;
eof = false;
}{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)