@@ -73,25 +73,25 @@ private Grpc() {
7373 public @interface TransportAttr {}
7474
7575 /**
76- * Creates a channel builder with a target string and credentials. The target can be either a
77- * valid {@link NameResolver}-compliant URI, or an authority string.
76+ * Creates a channel builder with a target string and credentials. The target can be either an RFC
77+ * 3986 URI, or an authority string.
78+ *
79+ * <p>Example URIs:
7880 *
79- * <p>A {@code NameResolver}-compliant URI is an absolute hierarchical URI as defined by {@link
80- * java.net.URI}. Example URIs:
8181 * <ul>
8282 * <li>{@code "dns:///foo.googleapis.com:8080"}</li>
8383 * <li>{@code "dns:///foo.googleapis.com"}</li>
8484 * <li>{@code "dns:///%5B2001:db8:85a3:8d3:1319:8a2e:370:7348%5D:443"}</li>
8585 * <li>{@code "dns://8.8.8.8/foo.googleapis.com:8080"}</li>
8686 * <li>{@code "dns://8.8.8.8/foo.googleapis.com"}</li>
8787 * <li>{@code "zookeeper://zk.example.com:9900/example_service"}</li>
88+ * <li>{@code "intent:#Intent;package=com.some.app;action=a;category=c;end;"}</li>
8889 * </ul>
8990 *
90- * <p>An authority string will be converted to a {@code NameResolver}-compliant URI, which has
91- * the scheme from the name resolver with the highest priority (e.g. {@code "dns"}),
92- * no authority, and the original authority string as its path after properly escaped.
93- * We recommend libraries to specify the schema explicitly if it is known, since libraries cannot
94- * know which NameResolver will be default during runtime.
91+ * <p>An authority string will be converted to a URI having the scheme of the name resolver with
92+ * the highest priority (e.g. {@code "dns"}), the empty string as the authority, and 'target' as
93+ * its path. We recommend libraries specify the scheme explicitly if it is known, since libraries
94+ * cannot know which NameResolver will be default at runtime.
9595 * Example authority strings:
9696 * <ul>
9797 * <li>{@code "localhost"}</li>
@@ -102,6 +102,14 @@ private Grpc() {
102102 * <li>{@code "[2001:db8:85a3:8d3:1319:8a2e:370:7348]"}</li>
103103 * <li>{@code "[2001:db8:85a3:8d3:1319:8a2e:370:7348]:443"}</li>
104104 * </ul>
105+ *
106+ * <p>We also recommend the URI form of `target` because the alternative is ambiguous. For
107+ * example, the target string `foo:8080` is a valid authority string with host `foo` and port
108+ * `8080` but it is also a valid RFC 3986 URI with scheme `foo` and path `8080`. {@code
109+ * NameResolver}s are discovered dynamically from your classpath using SPI, so it's hard to be
110+ * sure in advance how such a target will be resolved. A {@code NameResolver} for scheme `foo`
111+ * might someday make a host named `foo` unreachable! On the other hand, the 'dns:///foo:8080'
112+ * target will always behave the same.
105113 */
106114 public static ManagedChannelBuilder <?> newChannelBuilder (
107115 String target , ChannelCredentials creds ) {
@@ -118,9 +126,7 @@ public static ManagedChannelBuilder<?> newChannelBuilderForAddress(
118126 return newChannelBuilder (authorityFromHostAndPort (host , port ), creds );
119127 }
120128
121- /**
122- * Combine a host and port into an authority string.
123- */
129+ /** Combine a host and port into an authority string. */
124130 // A copy of GrpcUtil.authorityFromHostAndPort
125131 private static String authorityFromHostAndPort (String host , int port ) {
126132 try {
0 commit comments