[ISSUE-xxxx] Fix IPv6 address parsing across server and client components#17567
Open
xiaoyekanren wants to merge 1 commit intoapache:masterfrom
Open
[ISSUE-xxxx] Fix IPv6 address parsing across server and client components#17567xiaoyekanren wants to merge 1 commit intoapache:masterfrom
xiaoyekanren wants to merge 1 commit intoapache:masterfrom
Conversation
The address parsing methods in Utils.java used split(":") which cannot
correctly handle IPv6 addresses like [::1]:10710. This caused:
- NumberFormatException when parsing empty string as port
- ConfigNode/DataNode startup failure when configured with IPv6 addresses
Changes:
- hostAddress(): Wrap IPv6 addresses in brackets [ip]:port format
- fromRaftPeerAddressToTEndPoint(): Parse IPv6 format correctly
- fromRaftPeerProtoToTEndPoint(): Parse IPv6 format correctly
5ca65b2 to
ed12608
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Multiple components in IoTDB cannot correctly handle IPv6 addresses when configured with IPv6 endpoints like
[::1]:10710. Usingsplit(":")to parse IPv6 addresses causes:NumberFormatExceptionwhen parsing empty string as portinit_from_node_urlsfailureFor IPv6 address
[::1]:10710,split(":")produces:items[0]=[items[1]=""(empty string) ← Integer.parseInt throws exceptionitems[2]=1]items[3]=10710Solution
This PR fixes IPv6 address parsing in 3 components:
1. Ratis Consensus Utils (Server-side)
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/utils/Utils.javahostAddress()- Wrap IPv6 addresses in brackets[ip]:portformatfromRaftPeerAddressToTEndPoint()- Parse IPv6 format[ipv6]:portcorrectlyfromRaftPeerProtoToTEndPoint()- Parse IPv6 format correctly2. JDBC Client
iotdb-client/jdbc/src/main/java/org/apache/iotdb/jdbc/Utils.javaparseUrl()- Handle JDBC URLs likejdbc:iotdb://[::1]:6667/by detecting[ipv6]format3. Python Client
iotdb-client/client-py/iotdb/Session.pyinit_from_node_urls()- Parse IPv6 node URLs like[::1]:6667correctlyAffected Components
jdbc:iotdb://[::1]:6667/init_from_node_urlsfails[::1]:6667Test Plan
cn_internal_address=::1dn_rpc_address=::1jdbc:iotdb://[::1]:6667/Session.init_from_node_urls(["[::1]:6667"])