absurdfarce commented on code in PR #1913:
URL: 
https://github.com/apache/cassandra-java-driver/pull/1913#discussion_r1499621047


##########
core/src/main/java/com/datastax/oss/driver/internal/core/metadata/DefaultTopologyMonitor.java:
##########
@@ -494,28 +499,50 @@ private void savePort(DriverChannel channel) {
   @Nullable
   protected InetSocketAddress getBroadcastRpcAddress(
       @NonNull AdminRow row, @NonNull EndPoint localEndPoint) {
-    // in system.peers or system.local
-    InetAddress broadcastRpcInetAddress = row.getInetAddress("rpc_address");
-    if (broadcastRpcInetAddress == null) {
-      // in system.peers_v2 (Cassandra >= 4.0)
-      broadcastRpcInetAddress = row.getInetAddress("native_address");
-      if (broadcastRpcInetAddress == null) {
-        // This could only happen if system tables are corrupted, but handle 
gracefully
-        return null;
-      }
-    }
-    // system.local for Cassandra >= 4.0
-    Integer broadcastRpcPort = row.getInteger("rpc_port");
-    if (broadcastRpcPort == null || broadcastRpcPort == 0) {
-      // system.peers_v2
-      broadcastRpcPort = row.getInteger("native_port");
-      if (broadcastRpcPort == null || broadcastRpcPort == 0) {
-        // use the default port if no port information was found in the row;
-        // note that in rare situations, the default port might not be known, 
in which case we
-        // report zero, as advertised in the javadocs of Node and NodeInfo.
-        broadcastRpcPort = port == -1 ? 0 : port;
+
+    InetAddress broadcastRpcInetAddress = null;
+    Iterator<String> addrCandidates =
+        Iterators.forArray(
+            // in system.peers_v2 (Cassandra >= 4.0)
+            "native_address",
+            // DSE 6.8 introduced native_transport_address and 
native_transport_port for the
+            // listen address.
+            "native_transport_address",
+            // in system.peers or system.local
+            "rpc_address");
+
+    while (broadcastRpcInetAddress == null && addrCandidates.hasNext())
+      broadcastRpcInetAddress = row.getInetAddress(addrCandidates.next());
+    // This could only happen if system tables are corrupted, but handle 
gracefully
+    if (broadcastRpcInetAddress == null) return null;

Review Comment:
   Makes sense.  Yeah, I can add some logging in here.



-- 
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: commits-unsubscr...@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to