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

Fix LengthFieldStreamingDecoder#bytesToInt parse error #13808

Merged
merged 1 commit into from
Mar 1, 2024

Conversation

CHYhave
Copy link
Contributor

@CHYhave CHYhave commented Feb 29, 2024

What is the purpose of the change

bugfix for error parsing byte array to int
fix #13809

Brief changelog

old byteToInt

   protected static int bytesToInt(byte[] bytes) {
        return (bytes[0] << 24) & 0xFF | (bytes[1] << 16) & 0xFF | (bytes[2] << 8) & 0xFF | (bytes[3]) & 0xFF;
    }

new byteToInt

  protected static int bytesToInt(byte[] bytes) {
        return ((bytes[0] & 0xFF) << 24) | ((bytes[1] & 0xFF) << 16) | ((bytes[2] & 0xFF) << 8) | (bytes[3]) & 0xFF;
    }

Verifying this change

@CHYhave CHYhave force-pushed the 3.3_fix_byteToInt_parse_error branch from d213589 to 965af33 Compare February 29, 2024 08:25
Copy link
Member

@AlbumenJ AlbumenJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oxsean PTAL

Copy link

sonarcloud bot commented Feb 29, 2024

@oxsean
Copy link
Collaborator

oxsean commented Feb 29, 2024

@oxsean PTAL

@AlbumenJ LGTM
same as:

public static int bytes2int(byte[] b, int off) {

I'm a bit curious why this issue wasn't triggered before.

@AlbumenJ AlbumenJ merged commit 22b3c29 into apache:3.3 Mar 1, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants