What version of gRPC-Java are you using?
1.84.0 (grpc-netty-shaded)
What is your environment?
JDK 11 / 17 / 21, reproducible on macOS and Linux.
What did you expect to see?
A channel can be built for valid RFC 1123 hostnames whose last label starts with a digit. These are common in Kubernetes, where a service in namespace 1234-k8s-namespace is reachable as otlp.1234-k8s-namespace.
What did you see instead?
| Call |
Result |
ManagedChannelBuilder.forAddress("otlp.1234-k8s-namespace", 4317) |
IllegalArgumentException: Invalid host or port |
ManagedChannelBuilder.forTarget("otlp.1234-k8s-namespace:4317") |
IllegalArgumentException: Invalid DNS name |
ManagedChannelBuilder.forTarget("dns:///otlp.1234-k8s-namespace:4317") |
IllegalArgumentException: Invalid DNS name |
ManagedChannelBuilder.forTarget("localhost:4317") |
OK |
GrpcUtil.authorityFromHostAndPort and DnsNameResolver both validate the host with java.net.URI. URI follows RFC 2396, where the last label of a hostname must start with a letter, so URI.getHost() returns null for these names (JDK-8188305). RFC 1123 allows it, and DNS resolves them fine.
The only workaround I found is resolving the address yourself and passing a fixed SocketAddress, which loses re-resolution and load balancing.
Steps to reproduce the bug
ManagedChannelBuilder.forTarget("dns:///otlp.1234-k8s-namespace:4317").usePlaintext().build();
// java.lang.IllegalArgumentException: Invalid DNS name: otlp.1234-k8s-namespace
Downstream context: open-telemetry/opentelemetry-java#8745, where the OTLP exporter's grpc-java sender can't be used with these endpoints.
What version of gRPC-Java are you using?
1.84.0 (
grpc-netty-shaded)What is your environment?
JDK 11 / 17 / 21, reproducible on macOS and Linux.
What did you expect to see?
A channel can be built for valid RFC 1123 hostnames whose last label starts with a digit. These are common in Kubernetes, where a service in namespace
1234-k8s-namespaceis reachable asotlp.1234-k8s-namespace.What did you see instead?
ManagedChannelBuilder.forAddress("otlp.1234-k8s-namespace", 4317)IllegalArgumentException: Invalid host or portManagedChannelBuilder.forTarget("otlp.1234-k8s-namespace:4317")IllegalArgumentException: Invalid DNS nameManagedChannelBuilder.forTarget("dns:///otlp.1234-k8s-namespace:4317")IllegalArgumentException: Invalid DNS nameManagedChannelBuilder.forTarget("localhost:4317")GrpcUtil.authorityFromHostAndPortandDnsNameResolverboth validate the host withjava.net.URI.URIfollows RFC 2396, where the last label of a hostname must start with a letter, soURI.getHost()returnsnullfor these names (JDK-8188305). RFC 1123 allows it, and DNS resolves them fine.The only workaround I found is resolving the address yourself and passing a fixed
SocketAddress, which loses re-resolution and load balancing.Steps to reproduce the bug
Downstream context: open-telemetry/opentelemetry-java#8745, where the OTLP exporter's grpc-java sender can't be used with these endpoints.