-
Notifications
You must be signed in to change notification settings - Fork 4k
api: Summarize EquivalentAddressGroup toString #12600
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
base: master
Are you sure you want to change the base?
Conversation
|
|
||
| /** Unit tests for {@link CallOptions}. */ | ||
| @RunWith(JUnit4.class) | ||
| public class CallOptionsTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes in this test seem unrelated to the PR description. Can you move it to a separate PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback. I’ve reverted the CallOptionsTest refactor in this PR since it’s unrelated to the change. I can follow up with a separate PR if we still want that refactor.
| */ | ||
| @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1770") | ||
| public final class EquivalentAddressGroup { | ||
| private static final int MAX_ADDRESSES_TO_STRING = 100; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just make it package-private and access it directly from the tests without the use of reflection.
Background
EquivalentAddressGroup.toString() currently prints the full address list, which can become extremely large and noisy for big address sets. This makes logs and test output hard to read and can obscure useful information.
Changes
This PR adds a hard cap to the number of addresses rendered in toString() and summarizes the remainder (e.g., “... N more”). It also adds focused unit tests to validate the large-list and boundary behaviors, and refactors related CallOptionsTest assertions using a small Truth subject for clearer equivalence checks.
Purpose
Keep toString() output readable even with very large address lists
Ensure the summarization behavior is covered by unit tests
Improve clarity of CallOptions equivalence assertions in tests
Note
The summary threshold is defined as a private constant and is only used for output formatting. It does not change the underlying address data or behavior—only the string representation.
Fixes #12593