import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.client.reactive.JettyClientHttpConnector;
-import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
+import org.springframework.web.reactive.function.client.ClientRequest;
+import org.springframework.web.reactive.function.client.ClientResponse;
+import org.springframework.web.reactive.function.client.ExchangeFunction;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
.builder()
.clientConnector(new JettyClientHttpConnector())
.baseUrl(server.url("/").toString())
- .filter(errorHandlingFilter())
+ .filter(this::errorHandlingFilter)
.build();
}
.verify(Duration.ofSeconds(3));
}
- public static ExchangeFilterFunction errorHandlingFilter()
+ public Mono<ClientResponse> errorHandlingFilter(ClientRequest request, ExchangeFunction next)
{
- return (request, next) -> next.exchange(request).flatMap(response ->
+ return next.exchange(request).flatMap(response ->
{
if (response.statusCode() != null && (response.statusCode()
.is5xxServerError() || response.statusCode().is4xxClientError()))