Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-705

MarkShieldInputStream#reset should throw UnsupportedOperationException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.9.0
    • None
    • None

    Description

      The code of MarkShieldInputStream#reset is as follows:

       public void reset() throws IOException {
              throw new IOException("mark/reset not supported");
          }
      

      The message indicates that it is better to throw UnsupportedOperationException. Indeed, otehr classes throw that exception in similar contexts:

      WindowsLineEndingInputStream#mark

       public synchronized void mark(final int readlimit) {
              throw new UnsupportedOperationException("Mark not supported");
          }
      

      NullReader#reset:

      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;
          }

      Attachments

        Activity

          People

            ggregory Gary D. Gregory
            haozhong Hao Zhong
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: