Thrift
  1. Thrift
  2. THRIFT-1058

All ByteBuffers the client uses should be slice()ed

    Details

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

      Description

      Right now the code does something like yay so:

      return ByteBuffer.wrap(array, pos, len);

      The only problem is that .wrap(byte[],int,int) returns a ByteBuffer with position equal to pos and limit set to pos+len. Which means users cant used 'rewind' or position(0).

      It would be cleaner if the contract was "ByteBuffers will have position=0, limit=how much data you have".

      The way to accomplish this would be to:

      return ByteBuffer.wrap(array, pos, len).slice();

      In exchange for 1 extra object alloc (which the GC can clean up quick) we get the benefit of a easier to use BB interface.

        Activity

        ryan rawson created issue -
        Jeff Whiting made changes -
        Field Original Value New Value
        Attachment ByteBufferTest.java [ 12479621 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            ryan rawson
          • Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:

              Development