RATIS-2592. Ratis CLI and example peer-address parsers fail on IPv6 literal addresses#1509
Open
smengcl wants to merge 3 commits into
Open
RATIS-2592. Ratis CLI and example peer-address parsers fail on IPv6 literal addresses#1509smengcl wants to merge 3 commits into
smengcl wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes IPv6-literal handling in Ratis CLI and example peer parsers by avoiding naive split(":") parsing, leveraging NetUtils and adding tests to prevent regressions in IPv6-only environments.
Changes:
- Update
CliUtils.parseInetSocketAddressto useNetUtils.createSocketAddr(supports bracketed IPv6 literals). - Ensure
raftMetaConfwrites bracketed IPv6 literals viaNetUtils.address2String. - Refactor example peer parsing (
SubCommandBase.parsePeers) to correctly handle bracketed IPv6 hosts and add new IPv4/IPv6 parsing tests.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| ratis-test/src/test/java/org/apache/ratis/shell/cli/TestCliUtils.java | Adds unit tests for CLI address/peer parsing, including bracketed IPv6. |
| ratis-test/src/test/java/org/apache/ratis/shell/cli/sh/LocalCommandIntegrationTest.java | Adds an integration test ensuring raftMetaConf round-trips bracketed IPv6 addresses. |
| ratis-shell/src/main/java/org/apache/ratis/shell/cli/sh/local/RaftMetaConfCommand.java | Writes peer addresses using NetUtils.address2String to keep IPv6 literals bracketed. |
| ratis-shell/src/main/java/org/apache/ratis/shell/cli/CliUtils.java | Switches address parsing to NetUtils.createSocketAddr for IPv6 support. |
| ratis-examples/src/test/java/org/apache/ratis/examples/common/TestSubCommand.java | Adds tests for IPv4, IPv6, and mixed peer parsing. |
| ratis-examples/src/main/java/org/apache/ratis/examples/common/SubCommandBase.java | Refactors peer parsing to correctly separate host vs port list for bracketed IPv6 literals. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
22
to
28
| import java.util.Collection; | ||
| import java.util.Collections; | ||
| import org.apache.ratis.protocol.RaftPeer; | ||
| import org.junit.jupiter.api.Assertions; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.params.ParameterizedTest; | ||
| import org.junit.jupiter.params.provider.MethodSource; |
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.
Generated-by: Claude Code (Opus 4.8)
Several command-line address parsers in Ratis split host/port on a bare
:, which corrupts IPv6 literal addresses e.g.[::1]:6000. This makes the ratis sh CLI and the example applications unusable in IPv6-only environments, even though the core transport (gRPC/Netty bind + connect) and NetUtils address handling already support IPv6.What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/RATIS-2592
How was this patch tested?