[ 
https://issues.apache.org/jira/browse/CASSANDRA-1661?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12924617#action_12924617
 ] 

Jonathan Ellis commented on CASSANDRA-1661:
-------------------------------------------

bq. simplified with judicious use of mark() and get()

I worry that we're going to introduce very very tricky bugs if we don't treat 
position as immutable.  If BB/Thrift were sane about using offset to represent 
the start of what we're allowed to mess with, that would be another story, but 
it's not -- Thrift uses wrap to generate the BB it gives us, so position is the 
only indication we have of what a given BB is supposed to cover.

bq. ByteBufferTest is literally a test of ByteBuffers: I don't think it should 
be in C*

OTOH ByteBuffer is a tricky enough API (see: this ticket :) that I don't mind 
having BBT as an illustration of what is going on if not exactly a test.

Maybe docstring in BBUtil instead of actual tests?

> Use of ByteBuffer limit() must account for arrayOffset() 
> ---------------------------------------------------------
>
>                 Key: CASSANDRA-1661
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-1661
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 0.7.0
>            Reporter: T Jake Luciani
>            Assignee: T Jake Luciani
>             Fix For: 0.7.0
>
>         Attachments: 1661_v1.txt
>
>
> There are a few places in the code where it loops across a byte buffers 
> backing array wrong:
>         for (int i=bytes.position()+bytes.arrayOffset(); i<bytes.limit(); i++)
> This is incorrect as the limit() does not account for arrayOffset()
>               for (int i=bytes.position()+bytes.arrayOffset(); 
> i<bytes.limit()+bytes.arrayOffset(); i++)
> is the correct code.
> There is also a few places where the unit tests would fail if we used non 
> wrapped byte arrays.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to