Skip to content

Commit 8a57448

Browse files
Prevent long overflow in SNI address resolution
1 parent 342e2dc commit 8a57448

File tree

1 file changed

+1
-1
lines changed
  • core/src/main/java/com/datastax/oss/driver/internal/core/metadata

1 file changed

+1
-1
lines changed

Diff for: core/src/main/java/com/datastax/oss/driver/internal/core/metadata/SniEndPoint.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public InetSocketAddress resolve() {
6464
// The order of the returned address is unspecified. Sort by IP to make sure we get a true
6565
// round-robin
6666
Arrays.sort(aRecords, IP_COMPARATOR);
67-
int index = (aRecords.length == 1) ? 0 : (int) OFFSET.getAndIncrement() % aRecords.length;
67+
int index = (aRecords.length == 1) ? 0 : Math.abs((int) OFFSET.getAndIncrement()) % aRecords.length;
6868
return new InetSocketAddress(aRecords[index], proxyAddress.getPort());
6969
} catch (UnknownHostException e) {
7070
throw new IllegalArgumentException(

0 commit comments

Comments
 (0)