You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@bookkeeper.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2016/10/19 23:55:58 UTC

[jira] [Commented] (BOOKKEEPER-958) ZeroBuffer readOnlyBuffer returns ByteBuffer with 0 remaining bytes for length > 64k

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

ASF GitHub Bot commented on BOOKKEEPER-958:
-------------------------------------------

GitHub user reddycharan opened a pull request:

    https://github.com/apache/bookkeeper/pull/66

    BOOKKEEPER-958: Fix for ZeroBuffer Bug

    Fix for readOnlyBuffer of ZeroBuffer bug

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/reddycharan/bookkeeper zerobufferfix

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/bookkeeper/pull/66.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #66
    
----
commit 8e2c8bf62832989d7d689100900b6c5beeef0a7e
Author: Charan Reddy Guttapalem <cg...@salesforce.com>
Date:   2016-10-19T23:44:03Z

    BOOKKEEPER-958: Fix for ZeroBuffer Bug
    
    Fix for readOnlyBuffer of ZeroBuffer bug

----


> ZeroBuffer readOnlyBuffer returns ByteBuffer with 0 remaining bytes for length > 64k
> ------------------------------------------------------------------------------------
>
>                 Key: BOOKKEEPER-958
>                 URL: https://issues.apache.org/jira/browse/BOOKKEEPER-958
>             Project: Bookkeeper
>          Issue Type: Bug
>            Reporter: Charan Reddy Guttapalem
>            Assignee: Charan Reddy Guttapalem
>            Priority: Trivial
>
> in ZeroBuffer
> here, if the length is > zeroBytes.length (64K), then it is returning zero ByteBuffer but its position is set to limit and hence its remaining will be 0, which is not expected, but if it is < 64k then its position is set to 0 and the remaining will be length.
> Looking at the call hierearchy, it seems there are no callers for this function, but since this is utility class it needs to be corrected.
>     public static ByteBuffer readOnlyBuffer(int length) {
>         ByteBuffer buffer;
>         if (length <= zeroBytes.length) {
>             buffer = ByteBuffer.wrap(zeroBytes, 0, length);
>         }
>         else {
>             buffer = ByteBuffer.allocate(length);
>             put(buffer);
>         }
>         return buffer.asReadOnlyBuffer();
>     }



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