Add RFC 3986 URI support to "googleapis" #12704
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the googleapis Cloud-to-Prod (google-c2p) name resolver/provider to support the new RFC 3986-compliant io.grpc.Uri API, while adding supporting functionality and tests in io.grpc.Uri to better handle authority parsing/building.
Changes:
- Add
NameResolverProvider#newNameResolver(io.grpc.Uri, Args)overrides for google-c2p providers and a newGoogleCloudToProdNameResolver(io.grpc.Uri, ...)constructor. - Convert google-c2p unit tests to parameterized tests to exercise both
java.net.URIandio.grpc.Uricode paths. - Add
Uri.Builder#setRawAuthority(...)and new unit tests to validate authority component behavior and encoding/decoding.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| googleapis/src/test/java/io/grpc/googleapis/GoogleCloudToProdNameResolverTest.java | Parameterize tests to run against both java.net.URI and io.grpc.Uri constructors. |
| googleapis/src/test/java/io/grpc/googleapis/GoogleCloudToProdNameResolverProviderTest.java | Parameterize provider tests to cover both URI and io.grpc.Uri resolver creation paths. |
| googleapis/src/main/java/io/grpc/googleapis/GoogleCloudToProdNameResolverProvider.java | Add newNameResolver(Uri, Args) override while keeping URI override for migration. |
| googleapis/src/main/java/io/grpc/googleapis/GoogleCloudToProdNameResolver.java | Add io.grpc.Uri-based constructor and delegation logic. |
| googleapis/src/main/java/io/grpc/googleapis/GoogleCloudToProdExperimentalNameResolverProvider.java | Add newNameResolver(Uri, Args) passthrough override. |
| api/src/test/java/io/grpc/UriTest.java | Add tests covering setRawAuthority and authority clearing/empty authority behaviors. |
| api/src/main/java/io/grpc/Uri.java | Route authority parsing through new Builder#setRawAuthority and document lossy decoding in getAuthority(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
googleapis/src/main/java/io/grpc/googleapis/GoogleCloudToProdNameResolver.java
Show resolved
Hide resolved
googleapis/src/main/java/io/grpc/googleapis/GoogleCloudToProdNameResolver.java
Outdated
Show resolved
Hide resolved
googleapis/src/main/java/io/grpc/googleapis/GoogleCloudToProdNameResolver.java
Outdated
Show resolved
Hide resolved
googleapis/src/main/java/io/grpc/googleapis/GoogleCloudToProdNameResolverProvider.java
Outdated
Show resolved
Hide resolved
Good idea! I suggest annotating them as java.lang.Deprecated so that tools/IDEs can highlight them as being problematic. |
I added io.grpc.Uri.Builder#setRawAuthority to implement GoogleCloudToProdNameResolver's overrideAuthority() function. Thinking about this made me notice a related problem with Uri#getAuthority.