diff --git a/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/detail/DomainEventDetailService.kt b/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/detail/DomainEventDetailService.kt index ca89a90b38..e0751eafca 100644 --- a/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/detail/DomainEventDetailService.kt +++ b/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/detail/DomainEventDetailService.kt @@ -5,8 +5,10 @@ import org.springframework.beans.factory.annotation.Value import org.springframework.core.ParameterizedTypeReference import org.springframework.http.ResponseEntity import org.springframework.stereotype.Service +import org.springframework.web.client.HttpStatusCodeException import org.springframework.web.client.RestClient import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent +import uk.gov.justice.digital.hmpps.retry.retry import java.net.URI @Service @@ -28,11 +30,15 @@ class DomainEventDetailService( getDetail(validate(detailUrl), object : ParameterizedTypeReference() {}) fun getDetail(uri: URI, type: ParameterizedTypeReference): T = - requireNotNull(restClient).get().uri(uri).retrieve().body(type)!! + retry(3, listOf(HttpStatusCodeException::class)) { + requireNotNull(restClient).get().uri(uri).retrieve().body(type)!! + } final inline fun getDetailResponse(event: HmppsDomainEvent): ResponseEntity = getDetailResponse(validate(event.detailUrl), object : ParameterizedTypeReference() {}) fun getDetailResponse(uri: URI, type: ParameterizedTypeReference): ResponseEntity = - requireNotNull(restClient).get().uri(uri).retrieve().toEntity(type) + retry(3, listOf(HttpStatusCodeException::class)) { + requireNotNull(restClient).get().uri(uri).retrieve().toEntity(type) + } } \ No newline at end of file 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 1a4109e3f5..80274d5a4e 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 @@ -4,7 +4,6 @@ import org.springframework.http.HttpRequest import org.springframework.http.client.ClientHttpRequestExecution 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.io.IOException import java.time.Duration @@ -15,7 +14,7 @@ class RetryInterceptor(private val retries: Int = 3, private val delay: Duration request: HttpRequest, body: ByteArray, execution: ClientHttpRequestExecution - ): ClientHttpResponse = retry(retries, listOf(RestClientException::class, IOException::class), delay) { + ): ClientHttpResponse = retry(retries, listOf(IOException::class), delay) { execution.execute(request, body) } }