Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert byte[] to long error #537

Closed
shiyuhang0 opened this issue Feb 25, 2022 · 2 comments · Fixed by #538
Closed

convert byte[] to long error #537

shiyuhang0 opened this issue Feb 25, 2022 · 2 comments · Fixed by #538
Labels
severity/critical type/bug Something isn't working

Comments

@shiyuhang0
Copy link
Collaborator

Bug Report

1. Describe the bug

convert bytes to long error in TiChunkColumnVector#getLongFromBinary

2. Minimal reproduce step (Required)

when one byte of the byte[] < 0, you may get the wrong answer.
For example

        // generate byte[]
        ByteBuffer buffer = ByteBuffer.allocate(8);
        buffer.putLong(255);
        byte[] bytes =  buffer.array();
        // copy the code from getLongFromBinary
        long result = 0;
        for (byte b : bytes) {
            result = (result << 8) | b;
        }
        // answer is -1 rather than 255
        System.out.println(result);

5. What is your Java Client and TiKV version? (Required)

  • Client Java: master
@zz-jason
Copy link
Member

@marsishandsome I mark the severity as critical since the bug produces an incorrect result. @shiyuhang0 does it affect 3.1 and 3.0 releases?

shiyuhang0 added a commit to shiyuhang0/client-java that referenced this issue Feb 28, 2022
Signed-off-by: shiyuhang <[email protected]>
shiyuhang0 added a commit to shiyuhang0/client-java that referenced this issue Feb 28, 2022
Signed-off-by: shiyuhang <[email protected]>
shiyuhang0 added a commit to shiyuhang0/client-java that referenced this issue Feb 28, 2022
shiyuhang0 added a commit to shiyuhang0/client-java that referenced this issue Mar 1, 2022
Signed-off-by: shiyuhang <[email protected]>
shiyuhang0 added a commit to shiyuhang0/client-java that referenced this issue Mar 1, 2022
Signed-off-by: shiyuhang <[email protected]>
shiyuhang0 added a commit to shiyuhang0/client-java that referenced this issue Mar 1, 2022
@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity.

zz-jason added a commit that referenced this issue Mar 29, 2022
Co-authored-by: Liangliang Gu <[email protected]>
Co-authored-by: Jian Zhang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/critical type/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants