File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
core/src/main/java/com/datastax/oss/driver/internal/core/metadata Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 26
26
import java .util .Arrays ;
27
27
import java .util .Comparator ;
28
28
import java .util .Objects ;
29
- import java .util .concurrent .atomic .AtomicLong ;
29
+ import java .util .concurrent .atomic .AtomicInteger ;
30
30
31
31
public class SniEndPoint implements EndPoint {
32
- private static final AtomicLong OFFSET = new AtomicLong ();
32
+ private static final AtomicInteger OFFSET = new AtomicInteger ();
33
33
34
34
private final InetSocketAddress proxyAddress ;
35
35
private final String serverName ;
@@ -64,7 +64,10 @@ public InetSocketAddress resolve() {
64
64
// The order of the returned address is unspecified. Sort by IP to make sure we get a true
65
65
// round-robin
66
66
Arrays .sort (aRecords , IP_COMPARATOR );
67
- int index = (aRecords .length == 1 ) ? 0 : (int ) OFFSET .getAndIncrement () % aRecords .length ;
67
+ int index =
68
+ (aRecords .length == 1 )
69
+ ? 0
70
+ : OFFSET .getAndUpdate (x -> x == Integer .MAX_VALUE ? 0 : x + 1 ) % aRecords .length ;
68
71
return new InetSocketAddress (aRecords [index ], proxyAddress .getPort ());
69
72
} catch (UnknownHostException e ) {
70
73
throw new IllegalArgumentException (
You can’t perform that action at this time.
0 commit comments