From d7f9ba6548734f2e1666d6232dc2c775df316272 Mon Sep 17 00:00:00 2001 From: Istvan Toth Date: Wed, 17 Apr 2024 14:48:00 +0200 Subject: [PATCH] HBASE-28500 Rest Java client library assumes stateless servers (Addendum:fix spotbugs warning) (#5831) --- .../main/java/org/apache/hadoop/hbase/rest/client/Client.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 {