From 46f25e2d09783f24b9933f2fca06e9799c914885 Mon Sep 17 00:00:00 2001 From: Ugur Alpay Cenar Date: Wed, 28 Aug 2024 15:44:34 +0200 Subject: [PATCH] =?UTF-8?q?Ikke=20kj=C3=B8r=20retry=20p=C3=A5=20ResourceAc?= =?UTF-8?q?cessException?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nav/bidrag/grunnlag/exception/RestExceptionHandler.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/no/nav/bidrag/grunnlag/exception/RestExceptionHandler.kt b/src/main/kotlin/no/nav/bidrag/grunnlag/exception/RestExceptionHandler.kt index 808bd189..449a5cf1 100644 --- a/src/main/kotlin/no/nav/bidrag/grunnlag/exception/RestExceptionHandler.kt +++ b/src/main/kotlin/no/nav/bidrag/grunnlag/exception/RestExceptionHandler.kt @@ -4,7 +4,6 @@ import com.fasterxml.jackson.core.JacksonException import com.fasterxml.jackson.databind.JsonMappingException import com.fasterxml.jackson.databind.exc.InvalidFormatException import no.nav.bidrag.commons.ExceptionLogger -import no.nav.bidrag.commons.service.retryTemplate import no.nav.bidrag.commons.util.LoggingRetryListener import org.springframework.core.ParameterizedTypeReference import org.springframework.http.HttpEntity @@ -29,6 +28,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice import org.springframework.web.client.HttpClientErrorException import org.springframework.web.client.HttpServerErrorException import org.springframework.web.client.HttpStatusCodeException +import org.springframework.web.client.ResourceAccessException import org.springframework.web.client.RestClientException import org.springframework.web.client.RestTemplate import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException @@ -157,10 +157,9 @@ class HttpRetryPolicy( override fun canRetry(context: RetryContext): Boolean { val throwable = context.lastThrowable + val ignoreException = throwable is HttpStatusCodeException && ignoreHttpStatus.contains(throwable.statusCode) || throwable is ResourceAccessException val can = context.retryCount < maxAttempts && ( - context.lastThrowable == null || - throwable is HttpStatusCodeException && !ignoreHttpStatus.contains(throwable.statusCode) - ) + context.lastThrowable == null || !ignoreException ) if (!can && throwable != null) { context.setAttribute(RetryContext.NO_RECOVERY, true) } else {