Re: [PR] Prevent long overflow in SNI address resolution [cassandra-java-driver]

2025-04-16 Thread via GitHub


absurdfarce merged PR #2035:
URL: https://github.com/apache/cassandra-java-driver/pull/2035


-- 
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



Re: [PR] Prevent long overflow in SNI address resolution [cassandra-java-driver]

2025-04-15 Thread via GitHub


absurdfarce commented on PR #2035:
URL: 
https://github.com/apache/cassandra-java-driver/pull/2035#issuecomment-2807406215

   Re-run of Jenkins build after format fixes was as green as expected.  There 
were a few test failures but they were all of the 
[CASSJAVA-95](https://issues.apache.org/jira/browse/CASSJAVA-95) variety.
   
   @lukasz-antoniak can you update the commit message for this guy to include 
the "patch by" line?  I think once we have that this is ready to go in.


-- 
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



Re: [PR] Prevent long overflow in SNI address resolution [cassandra-java-driver]

2025-04-15 Thread via GitHub


lukasz-antoniak commented on PR #2035:
URL: 
https://github.com/apache/cassandra-java-driver/pull/2035#issuecomment-2803862634

   Done.


-- 
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



Re: [PR] Prevent long overflow in SNI address resolution [cassandra-java-driver]

2025-04-15 Thread via GitHub


absurdfarce commented on PR #2035:
URL: 
https://github.com/apache/cassandra-java-driver/pull/2035#issuecomment-2803891127

   Kicked off Jenkins tests again now that formatting has been resolved


-- 
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



Re: [PR] Prevent long overflow in SNI address resolution [cassandra-java-driver]

2025-04-14 Thread via GitHub


absurdfarce commented on PR #2035:
URL: 
https://github.com/apache/cassandra-java-driver/pull/2035#issuecomment-2803896583

   I keep wanting to try to make this work with IntStream but the concurrency 
win from using AtomicInteger is just too big a benefit to overcome.  I'll wait 
until the Jenkins run finishes but assuming there's nothing unexpected there 
I'm good with this.


-- 
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



Re: [PR] Prevent long overflow in SNI address resolution [cassandra-java-driver]

2025-04-11 Thread via GitHub


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



Re: [PR] Prevent long overflow in SNI address resolution [cassandra-java-driver]

2025-04-11 Thread via GitHub


lukasz-antoniak commented on code in PR #2035:
URL: 
https://github.com/apache/cassandra-java-driver/pull/2035#discussion_r2039378654


##
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((int) 
OFFSET.getAndIncrement()) % aRecords.length;

Review Comment:
   Good catch, changing.



-- 
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



Re: [PR] Prevent long overflow in SNI address resolution [cassandra-java-driver]

2025-04-11 Thread via GitHub


adutra commented on code in PR #2035:
URL: 
https://github.com/apache/cassandra-java-driver/pull/2035#discussion_r2039352232


##
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((int) 
OFFSET.getAndIncrement()) % aRecords.length;

Review Comment:
   Why is `OFFSET` an `AtomicLong`, shouldn't it be an `AtomicInteger`?



-- 
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