Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      I was reading ByteBufferInputStream.java; here is the skip method:

      public long skip(long n) throws IOException {
      long newPos = bb.position() + n;
      if (newPos > bb.remaining())

      { n = bb.remaining(); }

      bb.position(bb.position() + (int) n);
      return n;
      }

      The first two lines look wrong; we compare a "point" (position) to a "distance" (remaining). I think the test should be if (newPos >= bb.limit()).

      Or more simply:
      public long skip(long n) throws IOException {
      int remaining = buffer.remaining();
      if (n > remaining)

      { n = remaining; }

      buffer.position(buffer.position() + (int) n);
      return n;
      }

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Justin SB
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development