adutra commented on code in PR #2035: URL: https://github.com/apache/cassandra-java-driver/pull/2035#discussion_r2039487476
########## core/src/main/java/com/datastax/oss/driver/internal/core/metadata/SniEndPoint.java: ########## @@ -64,7 +64,7 @@ public InetSocketAddress resolve() { // The order of the returned address is unspecified. Sort by IP to make sure we get a true // round-robin Arrays.sort(aRecords, IP_COMPARATOR); - int index = (aRecords.length == 1) ? 0 : (int) OFFSET.getAndIncrement() % aRecords.length; + int index = (aRecords.length == 1) ? 0 : Math.abs(OFFSET.getAndIncrement()) % aRecords.length; Review Comment: I think `Math.abs` will yield `Integer.MIN_VALUE` for `Integer.MAX_VALUE + 1`. This looks safer to me: ```suggestion int index = (aRecords.length == 1) ? 0 : OFFSET.getAndUpdate(x -> x == Integer.MAX_VALUE ? 0 : x + 1) % aRecords.length; ``` -- 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: pr-unsubscr...@cassandra.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For additional commands, e-mail: pr-h...@cassandra.apache.org