diff --git a/sdk/java/src/main/java/com/chain/http/Client.java b/sdk/java/src/main/java/com/chain/http/Client.java index c19c14886d..5e968fe76d 100644 --- a/sdk/java/src/main/java/com/chain/http/Client.java +++ b/sdk/java/src/main/java/com/chain/http/Client.java @@ -318,7 +318,7 @@ private T post(String path, Object body, ResponseCreator respCreator) int idx = this.urlIndex.get(); URL endpointURL; try { - URI u = new URI(this.urls.get(idx).toString() + "/" + path); + URI u = new URI(this.urls.get(idx % this.urls.size()).toString() + "/" + path); u = u.normalize(); endpointURL = new URL(u.toString()); } catch (MalformedURLException ex) { @@ -473,7 +473,7 @@ private void nextURL(int failedIndex) { // A request to the url at failedIndex just failed. Move to the next // URL in the list. - int nextIndex = (failedIndex + 1) % this.urls.size(); + int nextIndex = failedIndex + 1; this.urlIndex.compareAndSet(failedIndex, nextIndex); }