Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.5.0
    • 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;
      }

        Attachments

        1. ZOOKEEPER-1843.patch
          5 kB
          Bill Havanki
        2. ZOOKEEPER-1843.v2.patch
          6 kB
          Bill Havanki

          Activity

            People

            • Assignee:
              bhavanki Bill Havanki
              Reporter:
              justinsb Justin SB
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: