RATIS-2402. Fix CallId overflow when parsing gRPC metadata.#1344
Merged
szetszwo merged 2 commits intoapache:masterfrom Feb 8, 2026
Merged
RATIS-2402. Fix CallId overflow when parsing gRPC metadata.#1344szetszwo merged 2 commits intoapache:masterfrom
szetszwo merged 2 commits intoapache:masterfrom
Conversation
Contributor
Author
|
I took a look at the error log, and it seems unrelated to our recent changes. |
szetszwo
reviewed
Feb 8, 2026
| if (trailers != null) { | ||
| final String callId = trailers.get(CALL_ID); | ||
| return callId != null ? Integer.parseInt(callId) : -1; | ||
| return callId != null ? Long.parseLong(callId) : -1; |
Contributor
There was a problem hiding this comment.
@slfan1989 , thanks for catching the bug! We need to use Long.parseUnsignedLong for uint64.
Contributor
Author
There was a problem hiding this comment.
Thanks for your suggestion! I've updated it to use Long.parseUnsignedLong for correctly parsing the uint64 call-id.
szetszwo
reviewed
Feb 8, 2026
Contributor
szetszwo
left a comment
There was a problem hiding this comment.
+1 the change looks good
Contributor
Author
@szetszwo Thank you so much for reviewing the code! |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changes were proposed in this pull request?
The
GrpcUtil.getCallId()method usesInteger.parseInt()to parse CallId from gRPC metadata, which causes overflow when CallId exceeds Integer.MAX_VALUE (2,147,483,647). This can result in incorrect CallId values or NumberFormatException in high-throughput scenarios where CallId may grow beyond 32-bit integer range.What is the link to the Apache JIRA
JIRA: RATIS-2402. Fix CallId overflow when parsing gRPC metadata.
How was this patch tested?
Add Junit Test.