From 6431522e49645f2ac6c6c0627624cfa521ab9760 Mon Sep 17 00:00:00 2001 From: Boyma Fahnbulleh Date: Wed, 8 Mar 2017 11:32:11 -0800 Subject: [PATCH] sdk/java: keep monotonic list of core urls --- sdk/java/src/main/java/com/chain/http/Client.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); }