From c031e1dbb9a4e7319b71d20ea5a8c477139b3038 Mon Sep 17 00:00:00 2001 From: Sergii Chernysh Date: Tue, 13 Oct 2020 12:13:50 +0300 Subject: [PATCH] Use TCF GVL fallback mechanism on any error during fetching vendor list version --- .../gdpr/vendorlist/VendorListService.java | 4 +--- .../vendorlist/VendorListServiceV1Test.java | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/prebid/server/privacy/gdpr/vendorlist/VendorListService.java b/src/main/java/org/prebid/server/privacy/gdpr/vendorlist/VendorListService.java index 19dbda73fe5..7427c6884fa 100644 --- a/src/main/java/org/prebid/server/privacy/gdpr/vendorlist/VendorListService.java +++ b/src/main/java/org/prebid/server/privacy/gdpr/vendorlist/VendorListService.java @@ -326,9 +326,7 @@ private Void handleError(Throwable exception, int version) { tcf, version, exception.getMessage()); } - if (exception instanceof MissingVendorListException) { - startUsingFallbackForVersion(version); - } + startUsingFallbackForVersion(version); return null; } diff --git a/src/test/java/org/prebid/server/privacy/gdpr/vendorlist/VendorListServiceV1Test.java b/src/test/java/org/prebid/server/privacy/gdpr/vendorlist/VendorListServiceV1Test.java index 8c22d0fc371..49d75317568 100644 --- a/src/test/java/org/prebid/server/privacy/gdpr/vendorlist/VendorListServiceV1Test.java +++ b/src/test/java/org/prebid/server/privacy/gdpr/vendorlist/VendorListServiceV1Test.java @@ -406,6 +406,23 @@ public void shouldReturnFallbackIfVendorListNotFound() { assertThat(future2).succeededWith(singletonMap(52, VendorV1.of(52, singleton(1), singleton(2)))); } + @Test + public void shouldReturnFallbackIfServerUnavailable() { + // given + givenHttpClientReturnsResponse(503, StringUtils.EMPTY); + + // when + + // first call triggers http request that results in 503 + final Future> future1 = vendorListService.forVersion(1); + // second call yields fallback vendor list + final Future> future2 = vendorListService.forVersion(1); + + // then + assertThat(future1).isFailed(); + assertThat(future2).succeededWith(singletonMap(52, VendorV1.of(52, singleton(1), singleton(2)))); + } + // Metrics tests @Test