teamconfx opened a new pull request, #4579:
URL: https://github.com/apache/cassandra/pull/4579

   This PR fix 
[CASSANDRA-21097](https://issues.apache.org/jira/browse/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:
   ```java
     private static final Pattern GOSSIP_ENDPOINT_PATTERN =
         
Pattern.compile("^[^\\s/]*/(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})(:\\d+)?$");
   ```
   
     2. Updated the parsing logic:
   ```java
     // 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
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to