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

Sylvain Lebresne commented on CASSANDRA-12381:
----------------------------------------------

Also, out of curiosity, could you indicate your source for the following claim:

bq. If a direct ByteBuffer has a backing array, we should not make any 
assumption on how it is actually used.

Cause [the hasArray() 
method|https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html#hasArray--]
 javadoc does states:

{quote}
Tells whether or not this buffer is backed by an accessible byte array.
If this method returns true then the array and arrayOffset methods may safely 
be invoked.
{quote}
and along with the javadoc on arrayOffset(), it sounds to me that what we do is 
completely fine. And {{hasArray}} sounds much more explicit to me in fact.

Honestly, I'd be surprised if what you say is true as that seems to suggest 
that the {{hasArray}} and {{arrayOffset}} methods are completely useless unless 
you also check {{isDirect()}} and that's not at all clearly stated in the 
javadoc.

> Verify use of ByteBuffer.hasArray() in whole code base
> ------------------------------------------------------
>
>                 Key: CASSANDRA-12381
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-12381
>             Project: Cassandra
>          Issue Type: Bug
>            Reporter: Robert Stupp
>            Assignee: Robert Stupp
>            Priority: Minor
>             Fix For: 3.0.x
>
>
> As [noted 
> here|https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html#allocateDirect-int-],
>  a direct {{ByteBuffer}} can have a backing array.
> If a direct {{ByteBuffer}} has a backing array, we should not make any 
> assumption on how it is actually used.
> This ticket is about to check whether uses of {{ByteBuffer.hasArray()}} need 
> to be replaced with {{ByteBuffer.isDirect()}}.
> (With CASSANDRA-11870 however, there is no way that such a direct 
> {{ByteBuffer}} has a backing array.)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to