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

[API-1356] Check for the minimum size of the bytes read only once per frame #21502

Merged
merged 2 commits into from Jun 2, 2022

Conversation

mdumandag
Copy link
Contributor

@mdumandag mdumandag commented May 31, 2022

Before this fix, while reading a message frame, we were mistakenly
checking that the bytes we haven't read yet are less than 6 bytes
each time the ClientMessageReader#readFrame is called.

This is problematic for frames that are read in multiple calls,
as the size of the last piece of the frame we are reading might be
actually less than 6 bytes and that is definitely valid. However,
in that case, we were not able to read the remaining part and
continue.

This PR aims to fix this problem by having that check only at the
beginning for each frame, only once per frame. Once we read the frame
length and flags, we will be able to read any number of bytes no
matter how small it is.

Closes #21498

Before this fix, while reading a message frame, we were mistakenly
checking that the bytes we haven't read yet are less than 6 bytes
each time the `ClientMessageReader#readFrame` is called.

This is problematic for frames that are read in multiple calls,
as the size of the last piece of the frame we are reading might be
actually less than 6 bytes and that is definitely valid. However,
in that case, we were not able to read the remaining part and
continue.

This PR aims to fix this problem by having that check only at the
beginning for each frame, only once per frame. Once we read the frame
length and flags, we will be able to read any number of bytes no
matter how small it is.
@emreyigit
Copy link
Contributor

Have commented. Also, it would be nice to have test case for the total length is less than 6 bytes. WDYT?

@mdumandag
Copy link
Contributor Author

mdumandag commented May 31, 2022

@emreyigit added the test in 3429208

@hz-devops-test
Copy link

The job Hazelcast-pr-compiler of your PR failed. (Hazelcast internal details: build log, artifacts).
Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log file
--------------------------
---------SUMMARY----------
--------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:animal-sniffer-maven-plugin:1.21:check (source-java8-check) on project hazelcast: Signature errors found. Verify them and ignore them with the proper annotation if needed. -> [Help 1]
--------------------------
---------ERRORS-----------
--------------------------
[ERROR] /home/jenkins/jenkins_slave/workspace/Hazelcast-pr-compiler_2/hazelcast/src/test/java/com/hazelcast/client/impl/protocol/util/ClientMessageReaderTest.java:179: Undefined reference: java.nio.ByteBuffer java.nio.ByteBuffer.limit(int)
--------------------------
[ERROR] /home/jenkins/jenkins_slave/workspace/Hazelcast-pr-compiler_2/hazelcast/src/test/java/com/hazelcast/client/impl/protocol/util/ClientMessageReaderTest.java:186: Undefined reference: java.nio.ByteBuffer java.nio.ByteBuffer.limit(int)
--------------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
All Languages Should Check Used by clients team to track fixes on the java client that should potentially backported to others Source: Internal PR or issue was opened by an employee Team: Client Type: Defect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ClientMessage frame read for a message may be broken in case of large messages [HZ-1200]
4 participants