From: Kai Moritz Date: Thu, 21 Nov 2019 12:24:39 +0000 (+0100) Subject: WIP: WebClient X-Git-Tag: wip-webclient~30 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=6fcd07c06f7cbc8f07b8c1ca01bf83e33467d4af;p=facebook-errors WIP: WebClient --- diff --git a/src/main/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunction.java b/src/main/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunction.java index 0b583f4..53bdd0b 100644 --- a/src/main/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunction.java +++ b/src/main/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunction.java @@ -1,6 +1,8 @@ package de.juplo.facebook.errors; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.web.reactive.function.client.ClientRequest; import org.springframework.web.reactive.function.client.ClientResponse; @@ -15,6 +17,9 @@ import reactor.core.publisher.Mono; */ public class GraphApiExchangeFilterFunction implements ExchangeFilterFunction { + private static final Logger LOG = + LoggerFactory.getLogger(GraphApiExchangeFilterFunction.class); + public static GraphApiExchangeFilterFunction INSTANCE = new GraphApiExchangeFilterFunction(); @@ -23,14 +28,15 @@ public class GraphApiExchangeFilterFunction implements ExchangeFilterFunction public Mono filter(ClientRequest request, ExchangeFunction next) { return - next - .exchange(request) - .flatMap(response -> - { - return - HttpStatus.Series.CLIENT_ERROR.equals(response.statusCode().series()) - ? Mono.error(GraphApiException.create(response)) - : Mono.just(response); - }); + next + .exchange(request) + .doOnError(e -> LOG.debug("ERROR: {}", e)) + .flatMap(response -> + { + return + HttpStatus.Series.CLIENT_ERROR.equals(response.statusCode().series()) + ? Mono.error(GraphApiException.create(response)) + : Mono.just(response); + }); } } diff --git a/src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java b/src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java index 2e3ae22..2c94a49 100644 --- a/src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java +++ b/src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java @@ -87,6 +87,6 @@ public class GraphApiExchangeFilterFunctionIntegrationTest assertEquals("(#613) Calls to stream have exceeded the rate of 600 calls per 600 seconds.", e.getMessage()); assertEquals(Type.OAuthException, e.getType()); }) - .verifyLater(); + .verify(Duration.ofSeconds(3)); } }