Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Hostnames whose last label starts with a digit are rejected (java.net.URI, JDK-8188305)

Đang mở
#13,075 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
65/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
backend, networking

Hướng nghiên cứu

The issue is in hostname validation using java.net.URI. Look at GrpcUtil.authorityFromHostAndPort and DnsNameResolver. The bug is that valid RFC 1123 hostnames with a digit-starting last label are rejected. Start by examining the validation logic and see how to bypass or replace the URI-based check while maintaining compatibility. Check for existing tests related to hostname validation. 'Done' means the channel builder accepts hostnames like 'otlp.1234-k8s-namespace' without throwing IllegalArgumentException.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Java
Star
12.1k
Fork
4k
Merge trung bình
2 ngày 3 giờ
Pull request đã merge (30 ngày)
30

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của grpc/grpc-java

Tất cả issue của grpc/grpc-java

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.