Skip to content
This repository was archived by the owner on Jan 31, 2022. It is now read-only.

Commit 9fae209

Browse files
robertmogosPLNech
authored andcommitted
Fix waitTask overflow (#428)
1 parent ae537a9 commit 9fae209

File tree

1 file changed

+3
-1
lines changed
  • algoliasearch/src/main/java/com/algolia/search/saas

1 file changed

+3
-1
lines changed

algoliasearch/src/main/java/com/algolia/search/saas/Index.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,9 @@ protected JSONObject waitTask(String taskID, long timeToWait) throws AlgoliaExce
13781378
} catch (InterruptedException e) {
13791379
continue;
13801380
}
1381-
timeToWait *= 2;
1381+
1382+
final long newTimeout = timeToWait * 2;
1383+
timeToWait = (newTimeout <= 0 || newTimeout >= MAX_TIME_MS_TO_WAIT) ? MAX_TIME_MS_TO_WAIT : newTimeout;
13821384
}
13831385
} catch (JSONException e) {
13841386
throw new AlgoliaException(e.getMessage());

0 commit comments

Comments
 (0)