-
Notifications
You must be signed in to change notification settings - Fork 102
feat: Add Javadoc for the client modules #563
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: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @kabir, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the documentation across the client modules of the A2A protocol. The primary goal is to provide developers with clear, comprehensive, and example-rich Javadoc for all public APIs, making it much easier to understand, integrate, and effectively utilize the A2A client library. The focus is on the practical application of the client, covering message handling, task management, and transport configuration in detail. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request adds comprehensive Javadoc documentation across the client modules. The added documentation is excellent, with clear explanations, usage examples, and cross-references that will significantly improve the developer experience. I've found a couple of areas for potential improvement in the API design that were highlighted by the new documentation. My specific comments are below. Overall, this is a fantastic contribution to the project's maintainability.
| /** | ||
| * Close this client and release all associated resources. | ||
| * <p> | ||
| * This method closes the underlying transport (HTTP connections, gRPC channels, etc.) | ||
| * and releases any other resources held by the client. After calling this method, the | ||
| * client instance should not be used further. | ||
| * <p> | ||
| * <b>Important:</b> Always close clients when done to avoid resource leaks: | ||
| * <pre>{@code | ||
| * Client client = Client.builder(card)...build(); | ||
| * try { | ||
| * client.sendMessage(...); | ||
| * } finally { | ||
| * client.close(); | ||
| * } | ||
| * // Or use try-with-resources if Client implements AutoCloseable | ||
| * }</pre> | ||
| */ |
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 Javadoc for the close() method on line 624 suggests using try-with-resources, which is excellent practice for resource management. To make this possible, the Client class (and its parent AbstractClient) should implement the java.lang.AutoCloseable interface. This would allow users to write cleaner and safer code.
Could you update AbstractClient to implement AutoCloseable? The close() method in AbstractClient doesn't throw any checked exceptions, so it's compatible with AutoCloseable.close().
This change would make the Client class AutoCloseable as well, and the try-with-resources example in the documentation will be directly applicable.
| /** | ||
| * Get the list of configured interceptors. | ||
| * <p> | ||
| * Returns the internal list of interceptors. Modifications to the returned list | ||
| * will affect this configuration. | ||
| * | ||
| * @return the list of configured interceptors (never null, but may be empty) | ||
| */ |
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.
This Javadoc correctly states that modifying the returned list will affect the configuration. This design breaks encapsulation and can lead to unexpected behavior. To make the API safer and more robust, getInterceptors() should return an unmodifiable list.
I recommend changing the implementation of getInterceptors() to return java.util.Collections.unmodifiableList(interceptors) and updating this Javadoc to reflect that the returned list is unmodifiable.
The focus is on the APIs users interact with rather than internal classes.
Fixes #476 🦕