Skip to content

RATIS-2592. Ratis CLI and example peer-address parsers fail on IPv6 literal addresses#1509

Open
smengcl wants to merge 3 commits into
apache:masterfrom
smengcl:RATIS-2592-cli-ipv6
Open

RATIS-2592. Ratis CLI and example peer-address parsers fail on IPv6 literal addresses#1509
smengcl wants to merge 3 commits into
apache:masterfrom
smengcl:RATIS-2592-cli-ipv6

Conversation

@smengcl

@smengcl smengcl commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

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?

  • Added unit tests

Copilot AI review requested due to automatic review settings July 7, 2026 22:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.parseInetSocketAddress to use NetUtils.createSocketAddr (supports bracketed IPv6 literals).
  • Ensure raftMetaConf writes bracketed IPv6 literals via NetUtils.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 thread ratis-shell/src/main/java/org/apache/ratis/shell/cli/CliUtils.java
Comment thread ratis-examples/src/main/java/org/apache/ratis/examples/common/SubCommandBase.java Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants