diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/Client.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/Client.java index 96cb5f290b0a..abf00f938c9b 100644 --- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/Client.java +++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/Client.java @@ -35,6 +35,7 @@ import java.util.Map; import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ThreadLocalRandom; import javax.net.ssl.SSLContext; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; @@ -270,7 +271,7 @@ public HttpResponse executePathOnly(Cluster cluster, HttpUriRequest method, Head throw new IOException("Cluster is empty"); } if (lastNodeId == null || !sticky) { - lastNodeId = (int) (cluster.nodes.size() * Math.random()); + lastNodeId = ThreadLocalRandom.current().nextInt(cluster.nodes.size()); } int start = lastNodeId; do {