Fix IPv6 endpoint handling in client and ops tools#18291
Conversation
There was a problem hiding this comment.
Pull request overview
This PR standardizes endpoint formatting across the CLI, table-model import/export tools, and ops scripts so IPv6 literals are handled safely (bracketed for display/URLs, and not split incorrectly when extracting ports).
Changes:
- Updated Java CLI and table import/export tools to build node URLs / JDBC URLs via
UrlUtils.formatTEndPointIpv4AndIpv6Url(...)for consistent IPv4/hostname/IPv6 formatting. - Improved Windows batch scripts to avoid
:-splitting issues with IPv6, and to correctly extract the listening port fromnetstatoutput. - Updated ops health-check output formatting (Unix + Windows) to display IPv6 endpoints with brackets.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| scripts/tools/windows/ops/health_check.bat | Uses an IPv6-safe endpoint delimiter and extracts ports from full netstat local endpoints to avoid missing IPv6 listeners. |
| scripts/tools/windows/ops/backup.bat | Updates netstat parsing to correctly detect IPv6 listeners when deciding whether IoTDB is running. |
| scripts/tools/ops/health_check.sh | Brackets IPv6 hosts in displayed host:ports output without affecting connectivity checks. |
| iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/ImportSchemaTable.java | Builds table session pool node URLs using the shared IPv4/IPv6 endpoint formatter. |
| iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/ExportSchemaTable.java | Builds table session pool node URLs using the shared IPv4/IPv6 endpoint formatter. |
| iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ImportDataTable.java | Builds table session pool node URLs using the shared IPv4/IPv6 endpoint formatter. |
| iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ExportDataTable.java | Builds table session builder node URLs using the shared IPv4/IPv6 endpoint formatter. |
| iotdb-client/cli/src/main/java/org/apache/iotdb/cli/Cli.java | Centralizes JDBC URL and login endpoint formatting via UrlUtils and localizes the login message. |
| iotdb-client/cli/src/main/i18n/zh/org/apache/iotdb/cli/i18n/CliMessages.java | Adds i18n template for the successful login message. |
| iotdb-client/cli/src/main/i18n/en/org/apache/iotdb/cli/i18n/CliMessages.java | Adds i18n template for the successful login message. |
Comments suppressed due to low confidence (1)
scripts/tools/windows/ops/backup.bat:98
- cn_internal_port_occupied is never set to 1 after detecting the ConfigNode internal port, so the guard
if !cn_internal_port_occupied!==0never flips and the script may repeatedly run :checkIfIOTDBProcess for every matching netstat row. Set the flag after the first match to make the guard effective.
) else if !local_port!==%cn_internal_port% (
if !cn_internal_port_occupied!==0 (
set spid=%%k
call :checkIfIOTDBProcess !spid! is_iotdb
if !is_iotdb!==1 (
set local_iotdb_occupied_ports=%cn_internal_port% !local_iotdb_occupied_ports!
)
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #18291 +/- ##
============================================
+ Coverage 42.83% 42.99% +0.16%
Complexity 374 374
============================================
Files 5362 5362
Lines 381409 381409
Branches 49509 49511 +2
============================================
+ Hits 163368 163989 +621
+ Misses 218041 217420 -621 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|


Description
Format endpoints consistently for IPv4, hostnames, and IPv6 addresses across the CLI, table-model import/export tools, and operational scripts.
The CLI and Java tools now use
UrlUtils.formatTEndPointIpv4AndIpv6Urlinstead of concatenating the host and port directly. Operational scripts preserve IPv6 hosts while checking ports, and display IPv6 endpoints with brackets. Windows port detection now reads the complete local endpoint fromnetstatbefore extracting its port, so IPv6 listeners are no longer missed.jdbc:iotdb://::1:6667/jdbc:iotdb://[::1]:6667/Successfully login at ::1:6667Successfully login at [::1]:6667host:portconcatenationhost:portconcatenation:::6667[::]:6667:, which breaks IPv6 literalsnetstatoutput on:, missing IPv6 listeners such as[::]:6667host:portoutputValidation
mvn spotless:apply -pl iotdb-client/cli -ammvn test-compile -pl iotdb-client/cli -am -DskipTestsmvn test-compile -pl iotdb-client/cli -am -P with-zh-locale -DskipTestsmvn package -pl distribution -am -DskipTestsbash -n scripts/tools/ops/health_check.shdn_rpc_address=::and verified CLI access through-h :: -p 16667.::; the imported row was queried successfully.::and displays[::]:16667.localhostand127.0.0.1.Windows batch changes were reviewed against IPv4 and IPv6
netstat /anoendpoint formats; runtime validation requires a Windows environment.