Skip to content

Conversation

@teamconfx
Copy link

This PR fix CASSANDRA-21097

Issue

ClusterUtils.parseGossipInfo() threw NullPointerException when parsing gossip info because it only checked for lines starting with "/" to identify endpoint addresses. When InetAddress.getHostName() is called (e.g., by JMX
methods), the hostname gets cached and toString() returns "localhost/127.0.0.1" instead of "/127.0.0.1".

Fix Applied

File: test/distributed/org/apache/cassandra/distributed/shared/ClusterUtils.java

  1. Added a regex pattern to match both formats:
  private static final Pattern GOSSIP_ENDPOINT_PATTERN =
      Pattern.compile("^[^\\s/]*/(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})(:\\d+)?$");
  1. Updated the parsing logic:
  // Before: 
if (line.startsWith("/"))
  // After:  
if (GOSSIP_ENDPOINT_PATTERN.matcher(line).matches())

Test Added

File: test/distributed/org/apache/cassandra/distributed/shared/ClusterUtilsParseGossipInfoTest.java

4 test cases covering:

  • Standard /IP:port format
  • Hostname prefix localhost/IP:port format
  • Mixed formats
  • Without port numbers

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.

1 participant