Hostnames whose last label starts with a digit are rejected (java.net.URI, JDK-8188305)
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 65/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- java
- 領域
- backend, networking
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Java
- スター
- 12.1k
- フォーク
- 4k
- 平均マージ
- 2日 3時間
- マージ済み PR(30日)
- 30
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
grpc/grpc-java のほかの issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
grpc/grpc-java#13052 · コメント 4 件 ·
メンテナーはふだん 2 日以内に返信
-
docs enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
grpc/grpc-java#10824 · コメント 8 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 70/100
メンテナーはふだん 2 日以内に返信
-
enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
メンテナーはふだん 2 日以内に返信
似ている issue
-
P2 testing
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信
-
area/core kind/bug status/triage team/core-shared
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
checkstyle/checkstyle#21755 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
spring-projects/spring-integration#11495 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信