Skip to content

Conversation

@slfan1989
Copy link
Contributor

What changes were proposed in this pull request?

The GrpcUtil.getCallId() method uses Integer.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.

ratis-proto/src/main/proto/Raft.proto:117 RaftRpcRequestProto.callId uint64
ratis-proto/src/main/proto/Raft.proto:90 callId uint64

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.

@slfan1989
Copy link
Contributor Author

I took a look at the error log, and it seems unrelated to our recent changes.

if (trailers != null) {
final String callId = trailers.get(CALL_ID);
return callId != null ? Integer.parseInt(callId) : -1;
return callId != null ? Long.parseLong(callId) : -1;
Copy link
Contributor

Choose a reason for hiding this comment

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

@slfan1989 , thanks for catching the bug! We need to use Long.parseUnsignedLong for uint64.

Copy link
Contributor Author

@slfan1989 slfan1989 Feb 8, 2026

Choose a reason for hiding this comment

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

Thanks for your suggestion! I've updated it to use Long.parseUnsignedLong for correctly parsing the uint64 call-id.

Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

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

+1 the change looks good

@szetszwo szetszwo merged commit 2bbff44 into apache:master Feb 8, 2026
16 checks passed
@slfan1989
Copy link
Contributor Author

+1 the change looks good

@szetszwo Thank you so much for reviewing the code!

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.

2 participants