feat(http-client): add Android support and implement SPI for A2AHttpClient#794
Open
sherryfox wants to merge 7 commits intoa2aproject:0.3.xfrom
Open
feat(http-client): add Android support and implement SPI for A2AHttpClient#794sherryfox wants to merge 7 commits intoa2aproject:0.3.xfrom
sherryfox wants to merge 7 commits intoa2aproject:0.3.xfrom
Conversation
…ct#789) Replacing Jackson with Gson for json (de)serialization Fixes #<issue_number_goes_here> 🦕 --------- Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com> Co-authored-by: Kabir Khan <kkhan@redhat.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the HTTP client creation by introducing a ServiceLoader-based factory and adds an Android-specific implementation. It also enhances JSON serialization for several record classes in the spec module by adding @JsonProperty annotations. Feedback indicates that the new AndroidA2AHttpClient is missing specific error handling for 401 and 403 status codes in its asynchronous SSE implementation, which should be added to match the synchronous logic.
c35332a to
ca14abd
Compare
Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Extract request id before jsonrpc validation so error responses include top-level id. Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
…lient - Introduce `AndroidA2AHttpClient` using `HttpURLConnection` for Android compatibility. - Implement `A2AHttpClientFactory` and `A2AHttpClientProvider` using `ServiceLoader` to decouple implementations. - Update `A2A` and transport providers to use the factory instead of hardcoding `JdkA2AHttpClient`. - Add `@JsonProperty` annotations to spec records to prevent parsing failures on Android.
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.
Summary of Changes
This PR introduces Android support for the A2A HTTP client, decouples the hardcoded JDK client using the Service Provider Interface (SPI) pattern, and aligns with the upcoming Gson migration by rebasing onto the
0.3-workflowsbranch.🌟 Key Highlights
HttpURLConnection.JdkA2AHttpClientand introduced a factory to resolve the best client automatically.📦 Detailed Changes
1. HTTP Client Factory & SPI Pattern
Introduced a factory and provider interface to allow pluggable HTTP client implementations via
ServiceLoader.A2AHttpClientFactory.java: Created to load implementations ofA2AHttpClientProviderand select the one with the highest priority.A2AHttpClientProvider.java: Introduced as the interface for providers.http-client/src/main/resources/META-INF/services/io.a2a.client.http.A2AHttpClientProviderhttp-client/src/main/resources_android/META-INF/services/io.a2a.client.http.A2AHttpClientProvider2. Decoupling
JdkA2AHttpClientRemoved hardcoded dependencies on
JdkA2AHttpClientacross the codebase.JdkA2AHttpClientnow implementsA2AHttpClientProviderwith a default priority of0.A2AHttpClientFactory.create()instead of direct instantiation:A2A.java(inclient/base)A2ACardResolver.java(inhttp-client)JSONRPCTransportProvider.java(inclient/transport/jsonrpc)RestTransportProvider.java(inclient/transport/rest)3.
AndroidA2AHttpClientAndroidA2AHttpClient.javausingHttpURLConnection(which does not have forbidden dependencies on Android).A2AHttpClientProviderwith a priority of100, making it the preferred choice in Android environments.4. Alignment with Gson Migration
ehsavoie/a2a-java:0.3-workflowsto support the move to Gson and avoid0.4leaks.specrecords (likeAgentCapabilities,TaskStatus, etc.) as they are not needed in the Gson environment.5. Documentation & Fixes
README.mdto reflect that the default HTTP client is resolved automatically via the factory rather than being hardcoded.4.2.0(from the fork) inexamples/cloud-deployment/k8s/02-kafka.yamlto ensure compatibility with the CI environment.🧪 Verification Results
mvn clean install -DskipTests=true.http-clientmodule passed successfully (mvn test -pl http-client), including a new test verifying the factory behavior.Description
Thank you for opening a Pull Request!
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
CONTRIBUTINGGuide.fix:which represents bug fixes, and correlates to a SemVer patch.feat:represents a new feature, and correlates to a SemVer minor.feat!:, orfix!:,refactor!:, etc., which represent a breaking change (indicated by the!) and will result in a SemVer major.Fixes #793 🦕