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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
mdumandag
added
Type: Defect
Team: Client
Source: Internal
PR or issue was opened by an employee
All Languages Should Check
Used by clients team to track fixes on the java client that should potentially backported to others
labels
May 31, 2022
This was referenced May 31, 2022
mdumandag
changed the title
Check for the minimum size of the bytes read only once per frame
[API-1356] Check for the minimum size of the bytes read only once per frame
May 31, 2022
emreyigit
reviewed
May 31, 2022
hazelcast/src/main/java/com/hazelcast/client/impl/protocol/ClientMessageReader.java
Show resolved
Hide resolved
emreyigit
reviewed
May 31, 2022
hazelcast/src/test/java/com/hazelcast/client/impl/protocol/util/ClientMessageReaderTest.java
Show resolved
Hide resolved
Have commented. Also, it would be nice to have test case for the total length is less than 6 bytes. WDYT? |
@emreyigit added the test in 3429208 |
The job 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) -------------------------- |
emreyigit
approved these changes
May 31, 2022
ihsandemir
approved these changes
Jun 2, 2022
This was referenced Jun 2, 2022
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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