Skip to content

feat(http-client): allow to construct a JdkA2AHttpClient with a prebuilt HttpClient#745

Open
maff wants to merge 1 commit intoa2aproject:mainfrom
maff:custom-http-client
Open

feat(http-client): allow to construct a JdkA2AHttpClient with a prebuilt HttpClient#745
maff wants to merge 1 commit intoa2aproject:mainfrom
maff:custom-http-client

Conversation

@maff
Copy link

@maff maff commented Mar 14, 2026

Description

A prebuilt HttpClient can be used to adapt for environment specific circumstances, e.g. by configuring a proxy or a specific SSL context.

  • Follow the CONTRIBUTING Guide.
  • Make your Pull Request title in the https://www.conventionalcommits.org/ specification.
    • Important Prefixes for release-please:
      • fix: which represents bug fixes, and correlates to a SemVer patch.
      • feat: represents a new feature, and correlates to a SemVer minor.
      • feat!:, or fix!:, refactor!:, etc., which represent a breaking change (indicated by the !) and will result in a SemVer major.
  • Ensure the tests pass
  • Appropriate READMEs were updated (if necessary)

Fixes #744 🦕

Allows to configure the HTTP client for environment specific circumstances, e.g. by configuring a proxy or a specific SSL context.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 enhances the JdkA2AHttpClient by providing a new constructor that accepts a pre-built java.net.http.HttpClient. This change significantly improves flexibility, allowing developers to apply custom configurations like proxy settings or specific SSL contexts to the underlying HTTP client, thereby adapting the SDK to various environment-specific requirements without replacing the core SDK implementation.

Highlights

  • New Constructor for JdkA2AHttpClient: Introduced a new constructor for JdkA2AHttpClient that allows users to provide a pre-configured java.net.http.HttpClient instance, enabling greater customization.
  • Enhanced Documentation: Updated the README.md with a clear code example demonstrating how to utilize the new constructor for custom HttpClient configurations, such as setting a connection timeout or proxy.
  • Comprehensive Unit Testing: Added new unit tests to JdkA2AHttpClientTest.java to ensure the new constructor functions correctly, verifies the use of the provided HttpClient, and handles invalid inputs like a null HttpClient parameter.
Changelog
  • README.md
    • Added documentation for customizing JdkA2AHttpClient with a pre-built HttpClient.
  • http-client/src/main/java/io/a2a/client/http/JdkA2AHttpClient.java
    • Added a new constructor JdkA2AHttpClient(HttpClient httpClient).
    • Modified the default constructor to delegate to the new constructor.
    • Imported io.a2a.util.Assert.checkNotNullParam for null parameter validation.
  • http-client/src/test/java/io/a2a/client/http/JdkA2AHttpClientTest.java
    • Added a new test file for JdkA2AHttpClient.
    • Implemented tests for the default constructor's functionality.
    • Implemented tests for the new constructor using a provided HttpClient with custom settings (e.g., proxy).
    • Implemented tests to verify null HttpClient parameter handling in the new constructor.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 introduces a valuable feature allowing the JdkA2AHttpClient to be constructed with a pre-built java.net.http.HttpClient. This enhances flexibility by enabling users to configure environment-specific settings like proxies or custom SSL contexts. The implementation is well-executed, featuring a new constructor with proper null-checking and a clean refactoring of the default constructor. The accompanying tests are thorough, covering the new functionality, regression, and edge cases. The documentation update in the README is also clear and helpful.

@maff maff changed the title feat(http-client): allow to construct a JdkA2AHttpClient with a prebuild HttpClient feat(http-client): allow to construct a JdkA2AHttpClient with a prebuilt HttpClient Mar 14, 2026
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.

[Feat]: allow building JdkA2AHttpClient with a preconfigured JDK HttpClient

1 participant