From 41cdfaad39ca00741aeca86b6079a7bb03cacf0a Mon Sep 17 00:00:00 2001 From: Anthony Britton <105213050+anthony-britton-moj@users.noreply.github.com> Date: Wed, 6 Dec 2023 10:26:51 +0000 Subject: [PATCH] increased initial duration to increase backoff (#2879) --- .../digital/hmpps/config/security/RetryInterceptor.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/oauth-client/src/main/kotlin/uk/gov/justice/digital/hmpps/config/security/RetryInterceptor.kt b/libs/oauth-client/src/main/kotlin/uk/gov/justice/digital/hmpps/config/security/RetryInterceptor.kt index c75a131c53..e2e07f9ccb 100644 --- a/libs/oauth-client/src/main/kotlin/uk/gov/justice/digital/hmpps/config/security/RetryInterceptor.kt +++ b/libs/oauth-client/src/main/kotlin/uk/gov/justice/digital/hmpps/config/security/RetryInterceptor.kt @@ -6,13 +6,15 @@ import org.springframework.http.client.ClientHttpRequestInterceptor import org.springframework.http.client.ClientHttpResponse import org.springframework.web.client.RestClientException import uk.gov.justice.digital.hmpps.retry.retry +import java.time.Duration -class RetryInterceptor : ClientHttpRequestInterceptor { +class RetryInterceptor(private val retries: Int = 3, private val delay: Duration = Duration.ofMillis(200)) : + ClientHttpRequestInterceptor { override fun intercept( request: HttpRequest, body: ByteArray, execution: ClientHttpRequestExecution - ): ClientHttpResponse = retry(3, listOf(RestClientException::class)) { + ): ClientHttpResponse = retry(retries, listOf(RestClientException::class), delay) { execution.execute(request, body) } }