Skip to content

Introduce io.grpc.Uri.#12535

Merged
jdcormie merged 7 commits intogrpc:masterfrom
jdcormie:uri
Dec 5, 2025
Merged

Introduce io.grpc.Uri.#12535
jdcormie merged 7 commits intogrpc:masterfrom
jdcormie:uri

Conversation

@jdcormie
Copy link
Copy Markdown
Member

@jdcormie jdcormie commented Nov 25, 2025

io.grpc.Uri is an implementation of RFC 3986 tailored for grpc-java's needs. It lifts some of the limitations of java.net.URI that currently prevent us from resolving target URIs like intent:#Intent;... See #12244 for more.

Marked @Internal for now but the plan is to eventually use this to replace java.net.URI in our public APIs such as NameResolver.Factory.

io.grpc.Uri is an implementation of RFC 3986 tailored for grpc-java's
needs. It lifts some of the limitations of java.net.URI that currently
prevent us from resolving target URIs like intent:#Intent;...
Copy link
Copy Markdown
Member

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks nice. It's slightly strange you can't create a builder directly, but that'd just have you do Uri.create("myscheme:").toBuilder(), which seems pretty clear and guarantees there is a scheme.

Comment thread api/src/main/java/io/grpc/Uri.java Outdated
Comment thread api/src/main/java/io/grpc/Uri.java Outdated
Comment thread api/src/main/java/io/grpc/Uri.java
Comment thread api/src/main/java/io/grpc/Uri.java Outdated
@jdcormie
Copy link
Copy Markdown
Member Author

jdcormie commented Dec 5, 2025

This looks nice. It's slightly strange you can't create a builder directly, but that'd just have you do Uri.create("myscheme:").toBuilder(), which seems pretty clear and guarantees there is a scheme.

Thanks! Actually the Builder() ctor is public. My intention is for users to write code like:

Uri uri =
        new Uri.Builder()
            .setScheme("http")
            .setHost("grpc.io")
            .setPath("/index.html")
            .build();

Maybe there should be a public static newBuilder() method instead to match Attributes and CreateSubchannelArgs and MethodDescriptor ... ?

For consistency with the builder pattern elsewhere in grpc-java
@ejona86
Copy link
Copy Markdown
Member

ejona86 commented Dec 5, 2025

Ah, I see. Yeah, it would match our other APIs more to have a newBuilder(). You should probably add a note to the API that creates a builder that scheme must be set before build().

Comment thread api/src/main/java/io/grpc/Uri.java
@jdcormie jdcormie merged commit eb8a63c into grpc:master Dec 5, 2025
17 checks passed
@jdcormie jdcormie deleted the uri branch December 6, 2025 00:09
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants