File tree Expand file tree Collapse file tree
main/kotlin/com/lithic/api/core/http
test/kotlin/com/lithic/api/core/http Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -178,12 +178,12 @@ private constructor(
178178 }
179179
180180 // Apply exponential backoff, but not more than the max.
181- val backoffSeconds = min(0.5 * 2.0 .pow(retries - 1 ), 2 .0 )
181+ val backoffSeconds = min(0.5 * 2.0 .pow(retries - 1 ), 8 .0 )
182182
183183 // Apply some jitter
184- val jitter = ThreadLocalRandom .current().nextDouble()
184+ val jitter = 1.0 - 0.25 * ThreadLocalRandom .current().nextDouble()
185185
186- return (TimeUnit .SECONDS .toMillis(1 ) * backoffSeconds + jitter).toLong()
186+ return (TimeUnit .SECONDS .toMillis(1 ) * backoffSeconds * jitter).toLong()
187187 }
188188
189189 private fun sleepAsync (millis : Long ): CompletableFuture <Void > {
Original file line number Diff line number Diff line change @@ -77,7 +77,8 @@ internal class RetryingHttpClientTest {
7777 .willReturn(ok())
7878 .willSetStateTo(" COMPLETED" )
7979 )
80- val retryingClient = RetryingHttpClient .builder().httpClient(httpClient).build()
80+ val retryingClient =
81+ RetryingHttpClient .builder().httpClient(httpClient).maxRetries(2 ).build()
8182 val response = retryingClient.execute(request)
8283 assertThat(response.statusCode()).isEqualTo(200 )
8384 verify(3 , postRequestedFor(urlPathEqualTo(" /something" )))
You can’t perform that action at this time.
0 commit comments