diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java index 40de0c2449..ec0c11fd1d 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java @@ -67,6 +67,7 @@ import org.springframework.security.web.server.WebFilterChainProxy; import org.springframework.test.util.ReflectionTestUtils; import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.reactive.function.client.ClientResponse; import org.springframework.web.reactive.function.client.WebClient; import static org.assertj.core.api.Assertions.assertThat; @@ -269,7 +270,8 @@ class ReactiveCloudFoundryActuatorAutoConfigurationTests { "cloudFoundrySecurityService"); WebClient webClient = (WebClient) ReflectionTestUtils.getField(interceptorSecurityService, "webClient"); - webClient.get().uri("https://self-signed.badssl.com/").exchange().block(Duration.ofSeconds(30)); + webClient.get().uri("https://self-signed.badssl.com/").exchangeToMono(ClientResponse::releaseBody) + .block(Duration.ofSeconds(30)); }); } @@ -285,8 +287,9 @@ class ReactiveCloudFoundryActuatorAutoConfigurationTests { "cloudFoundrySecurityService"); WebClient webClient = (WebClient) ReflectionTestUtils.getField(interceptorSecurityService, "webClient"); - assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> webClient.get() - .uri("https://self-signed.badssl.com/").exchange().block(Duration.ofSeconds(30))) + assertThatExceptionOfType(RuntimeException.class) + .isThrownBy(() -> webClient.get().uri("https://self-signed.badssl.com/") + .exchangeToMono(ClientResponse::releaseBody).block(Duration.ofSeconds(30))) .withCauseInstanceOf(SSLException.class); }); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/client/WebClientMetricsConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/client/WebClientMetricsConfigurationTests.java index f14b935177..2a3d619720 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/client/WebClientMetricsConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/client/WebClientMetricsConfigurationTests.java @@ -38,6 +38,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpStatus; import org.springframework.http.client.reactive.ClientHttpConnector; import org.springframework.mock.http.client.reactive.MockClientHttpResponse; +import org.springframework.web.reactive.function.client.ClientResponse; import org.springframework.web.reactive.function.client.WebClient; import static org.assertj.core.api.Assertions.assertThat; @@ -111,7 +112,8 @@ class WebClientMetricsConfigurationTests { WebClient webClient = mockWebClient(context.getBean(WebClient.Builder.class)); MeterRegistry registry = context.getBean(MeterRegistry.class); for (int i = 0; i < 3; i++) { - webClient.get().uri("https://example.org/projects/" + i).exchange().block(Duration.ofSeconds(30)); + webClient.get().uri("https://example.org/projects/" + i).exchangeToMono(ClientResponse::releaseBody) + .block(Duration.ofSeconds(30)); } return registry; } @@ -119,8 +121,8 @@ class WebClientMetricsConfigurationTests { private void validateWebClient(WebClient.Builder builder, MeterRegistry registry) { WebClient webClient = mockWebClient(builder); assertThat(registry.find("http.client.requests").meter()).isNull(); - webClient.get().uri("https://example.org/projects/{project}", "spring-boot").exchange() - .block(Duration.ofSeconds(30)); + webClient.get().uri("https://example.org/projects/{project}", "spring-boot") + .exchangeToMono(ClientResponse::releaseBody).block(Duration.ofSeconds(30)); assertThat(registry.find("http.client.requests").tags("uri", "/projects/{project}").meter()).isNotNull(); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/servlet/WebMvcEndpointChildContextConfigurationIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/servlet/WebMvcEndpointChildContextConfigurationIntegrationTests.java index d116acfbeb..3df8f0c392 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/servlet/WebMvcEndpointChildContextConfigurationIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/servlet/WebMvcEndpointChildContextConfigurationIntegrationTests.java @@ -19,11 +19,13 @@ package org.springframework.boot.actuate.autoconfigure.web.servlet; import java.util.Collections; import java.util.Map; import java.util.function.Consumer; +import java.util.function.Function; import javax.validation.Valid; import javax.validation.constraints.NotEmpty; import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointAutoConfiguration; @@ -40,6 +42,7 @@ import org.springframework.boot.test.context.runner.ContextConsumer; import org.springframework.boot.test.context.runner.WebApplicationContextRunner; import org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer; import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext; +import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -74,9 +77,8 @@ class WebMvcEndpointChildContextConfigurationIntegrationTests { @Test // gh-17938 void errorEndpointIsUsedWithEndpoint() { this.runner.run(withWebTestClient((client) -> { - ClientResponse response = client.get().uri("actuator/fail").accept(MediaType.APPLICATION_JSON).exchange() - .block(); - Map body = getResponseBody(response); + Map body = client.get().uri("actuator/fail").accept(MediaType.APPLICATION_JSON) + .exchangeToMono(toResponseBody()).block(); assertThat(body).hasEntrySatisfying("exception", (value) -> assertThat(value).asString().contains("IllegalStateException")); assertThat(body).hasEntrySatisfying("message", @@ -88,9 +90,8 @@ class WebMvcEndpointChildContextConfigurationIntegrationTests { void errorPageAndErrorControllerIncludeDetails() { this.runner.withPropertyValues("server.error.include-stacktrace=always", "server.error.include-message=always") .run(withWebTestClient((client) -> { - ClientResponse response = client.get().uri("actuator/fail").accept(MediaType.APPLICATION_JSON) - .exchange().block(); - Map body = getResponseBody(response); + Map body = client.get().uri("actuator/fail").accept(MediaType.APPLICATION_JSON) + .exchangeToMono(toResponseBody()).block(); assertThat(body).hasEntrySatisfying("message", (value) -> assertThat(value).asString().contains("Epic Fail")); assertThat(body).hasEntrySatisfying("trace", (value) -> assertThat(value).asString() @@ -101,9 +102,8 @@ class WebMvcEndpointChildContextConfigurationIntegrationTests { @Test void errorEndpointIsUsedWithRestControllerEndpoint() { this.runner.run(withWebTestClient((client) -> { - ClientResponse response = client.get().uri("actuator/failController").accept(MediaType.APPLICATION_JSON) - .exchange().block(); - Map body = getResponseBody(response); + Map body = client.get().uri("actuator/failController").accept(MediaType.APPLICATION_JSON) + .exchangeToMono(toResponseBody()).block(); assertThat(body).hasEntrySatisfying("exception", (value) -> assertThat(value).asString().contains("IllegalStateException")); assertThat(body).hasEntrySatisfying("message", @@ -114,10 +114,9 @@ class WebMvcEndpointChildContextConfigurationIntegrationTests { @Test void errorEndpointIsUsedWithRestControllerEndpointOnBindingError() { this.runner.run(withWebTestClient((client) -> { - ClientResponse response = client.post().uri("actuator/failController") - .bodyValue(Collections.singletonMap("content", "")).accept(MediaType.APPLICATION_JSON).exchange() - .block(); - Map body = getResponseBody(response); + Map body = client.post().uri("actuator/failController") + .bodyValue(Collections.singletonMap("content", "")).accept(MediaType.APPLICATION_JSON) + .exchangeToMono(toResponseBody()).block(); assertThat(body).hasEntrySatisfying("exception", (value) -> assertThat(value).asString().contains("MethodArgumentNotValidException")); assertThat(body).hasEntrySatisfying("message", @@ -134,9 +133,9 @@ class WebMvcEndpointChildContextConfigurationIntegrationTests { }; } - @SuppressWarnings("unchecked") - private Map getResponseBody(ClientResponse response) { - return response.bodyToMono(Map.class).block(); + private Function>> toResponseBody() { + return ((clientResponse) -> clientResponse.bodyToMono(new ParameterizedTypeReference>() { + })); } @Endpoint(id = "fail") diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchReactiveHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchReactiveHealthIndicator.java index a71b0d199c..67adaa9ebe 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchReactiveHealthIndicator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchReactiveHealthIndicator.java @@ -56,6 +56,7 @@ public class ElasticsearchReactiveHealthIndicator extends AbstractReactiveHealth return this.client.execute(this::getHealth).flatMap((response) -> doHealthCheck(builder, response)); } + @SuppressWarnings("deprecation") // Requires an update in ReactiveElasticsearchClient private Mono getHealth(WebClient webClient) { return webClient.get().uri("/_cluster/health/").exchange(); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/WebClientAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/WebClientAutoConfigurationTests.java index ea2ba8fbda..98e6081a65 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/WebClientAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/WebClientAutoConfigurationTests.java @@ -20,6 +20,7 @@ import java.net.URI; import java.time.Duration; import org.junit.jupiter.api.Test; +import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import org.springframework.boot.autoconfigure.AutoConfigurations; @@ -88,6 +89,7 @@ class WebClientAutoConfigurationTests { void shouldGetPrototypeScopedBean() { this.contextRunner.withUserConfiguration(WebClientCustomizerConfig.class).run((context) -> { ClientHttpResponse response = mock(ClientHttpResponse.class); + given(response.getBody()).willReturn(Flux.empty()); given(response.getHeaders()).willReturn(new HttpHeaders()); ClientHttpConnector firstConnector = mock(ClientHttpConnector.class); given(firstConnector.connect(any(), any(), any())).willReturn(Mono.just(response)); @@ -98,8 +100,8 @@ class WebClientAutoConfigurationTests { WebClient.Builder secondBuilder = context.getBean(WebClient.Builder.class); secondBuilder.clientConnector(secondConnector).baseUrl("https://second.example.org"); assertThat(firstBuilder).isNotEqualTo(secondBuilder); - firstBuilder.build().get().uri("/foo").exchange().block(Duration.ofSeconds(30)); - secondBuilder.build().get().uri("/foo").exchange().block(Duration.ofSeconds(30)); + firstBuilder.build().get().uri("/foo").retrieve().toBodilessEntity().block(Duration.ofSeconds(30)); + secondBuilder.build().get().uri("/foo").retrieve().toBodilessEntity().block(Duration.ofSeconds(30)); verify(firstConnector).connect(eq(HttpMethod.GET), eq(URI.create("https://first.example.org/foo")), any()); verify(secondConnector).connect(eq(HttpMethod.GET), eq(URI.create("https://second.example.org/foo")), any()); diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientAutoConfigurationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientAutoConfigurationTests.java index 3bd6d68a91..61be82c7d2 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebTestClientAutoConfigurationTests.java @@ -74,7 +74,7 @@ class WebTestClientAutoConfigurationTests { this.contextRunner.withUserConfiguration(BaseConfiguration.class) .withPropertyValues("spring.test.webtestclient.timeout=15m").run((context) -> { WebTestClient webTestClient = context.getBean(WebTestClient.class); - assertThat(webTestClient).hasFieldOrPropertyWithValue("timeout", Duration.ofMinutes(15)); + assertThat(webTestClient).hasFieldOrPropertyWithValue("responseTimeout", Duration.ofMinutes(15)); }); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/netty/NettyReactiveWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/netty/NettyReactiveWebServerFactoryTests.java index d2890c7076..c7cb4b8fc2 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/netty/NettyReactiveWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/netty/NettyReactiveWebServerFactoryTests.java @@ -140,7 +140,7 @@ class NettyReactiveWebServerFactoryTests extends AbstractReactiveWebServerFactor WebClient client = WebClient.builder().baseUrl("https://localhost:" + this.webServer.getPort()) .clientConnector(connector).build(); return client.post().uri("/test").contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromValue("Hello World")) - .exchange().flatMap((response) -> response.bodyToMono(String.class)); + .retrieve().bodyToMono(String.class); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactoryTests.java index 9de21c3af3..d6bb518e5d 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactoryTests.java @@ -143,8 +143,7 @@ class UndertowReactiveWebServerFactoryTests extends AbstractReactiveWebServerFac this.webServer.start(); WebClient client = getWebClient(this.webServer.getPort()).build(); Mono result = client.post().uri("/test").contentType(MediaType.TEXT_PLAIN) - .body(BodyInserters.fromValue("Hello World")).exchange() - .flatMap((response) -> response.bodyToMono(String.class)); + .body(BodyInserters.fromValue("Hello World")).retrieve().bodyToMono(String.class); assertThat(result.block(Duration.ofSeconds(30))).isEqualTo("Hello World"); File accessLog = new File(accessLogDirectory, expectedFile); awaitFile(accessLog); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java index d3d90c9fc1..1a7ed7191a 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java @@ -70,6 +70,7 @@ import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.util.SocketUtils; import org.springframework.util.unit.DataSize; import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.client.ClientResponse; import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.reactive.function.client.WebClientRequestException; @@ -110,8 +111,8 @@ public abstract class AbstractReactiveWebServerFactoryTests { return port; }); Mono result = getWebClient(this.webServer.getPort()).build().post().uri("/test") - .contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromValue("Hello World")).exchange() - .flatMap((response) -> response.bodyToMono(String.class)); + .contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromValue("Hello World")).retrieve() + .bodyToMono(String.class); assertThat(result.block(Duration.ofSeconds(30))).isEqualTo("Hello World"); assertThat(this.webServer.getPort()).isEqualTo(specificPort); } @@ -139,8 +140,7 @@ public abstract class AbstractReactiveWebServerFactoryTests { WebClient client = WebClient.builder().baseUrl("https://localhost:" + this.webServer.getPort()) .clientConnector(connector).build(); Mono result = client.post().uri("/test").contentType(MediaType.TEXT_PLAIN) - .body(BodyInserters.fromValue("Hello World")).exchange() - .flatMap((response) -> response.bodyToMono(String.class)); + .body(BodyInserters.fromValue("Hello World")).retrieve().bodyToMono(String.class); assertThat(result.block(Duration.ofSeconds(30))).isEqualTo("Hello World"); } @@ -161,8 +161,7 @@ public abstract class AbstractReactiveWebServerFactoryTests { .clientConnector(connector).build(); Mono result = client.post().uri("/test").contentType(MediaType.TEXT_PLAIN) - .body(BodyInserters.fromValue("Hello World")).exchange() - .flatMap((response) -> response.bodyToMono(String.class)); + .body(BodyInserters.fromValue("Hello World")).retrieve().bodyToMono(String.class); StepVerifier.setDefaultTimeout(Duration.ofSeconds(30)); StepVerifier.create(result).expectNext("Hello World").verifyComplete(); @@ -234,8 +233,7 @@ public abstract class AbstractReactiveWebServerFactoryTests { WebClient client = WebClient.builder().baseUrl("https://localhost:" + this.webServer.getPort()) .clientConnector(clientConnector).build(); Mono result = client.post().uri("/test").contentType(MediaType.TEXT_PLAIN) - .body(BodyInserters.fromValue("Hello World")).exchange() - .flatMap((response) -> response.bodyToMono(String.class)); + .body(BodyInserters.fromValue("Hello World")).retrieve().bodyToMono(String.class); assertThat(result.block(Duration.ofSeconds(30))).isEqualTo("Hello World"); } @@ -267,8 +265,7 @@ public abstract class AbstractReactiveWebServerFactoryTests { WebClient client = WebClient.builder().baseUrl("https://localhost:" + this.webServer.getPort()) .clientConnector(clientConnector).build(); Mono result = client.post().uri("/test").contentType(MediaType.TEXT_PLAIN) - .body(BodyInserters.fromValue("Hello World")).exchange() - .flatMap((response) -> response.bodyToMono(String.class)); + .body(BodyInserters.fromValue("Hello World")).retrieve().bodyToMono(String.class); StepVerifier.create(result).expectError(WebClientRequestException.class).verify(Duration.ofSeconds(10)); } @@ -285,7 +282,7 @@ public abstract class AbstractReactiveWebServerFactoryTests { @Test protected void compressionOfResponseToGetRequest() { WebClient client = prepareCompressionTest(); - ResponseEntity response = client.get().exchange().flatMap((res) -> res.toEntity(Void.class)) + ResponseEntity response = client.get().exchangeToMono(ClientResponse::toBodilessEntity) .block(Duration.ofSeconds(30)); assertResponseIsCompressed(response); } @@ -293,7 +290,7 @@ public abstract class AbstractReactiveWebServerFactoryTests { @Test protected void compressionOfResponseToPostRequest() { WebClient client = prepareCompressionTest(); - ResponseEntity response = client.post().exchange().flatMap((res) -> res.toEntity(Void.class)) + ResponseEntity response = client.post().exchangeToMono(ClientResponse::toBodilessEntity) .block(Duration.ofSeconds(30)); assertResponseIsCompressed(response); } @@ -304,7 +301,7 @@ public abstract class AbstractReactiveWebServerFactoryTests { compression.setEnabled(true); compression.setMinResponseSize(DataSize.ofBytes(3001)); WebClient client = prepareCompressionTest(compression); - ResponseEntity response = client.get().exchange().flatMap((res) -> res.toEntity(Void.class)) + ResponseEntity response = client.get().exchangeToMono(ClientResponse::toBodilessEntity) .block(Duration.ofSeconds(30)); assertResponseIsNotCompressed(response); } @@ -315,7 +312,7 @@ public abstract class AbstractReactiveWebServerFactoryTests { compression.setEnabled(true); compression.setMimeTypes(new String[] { "application/json" }); WebClient client = prepareCompressionTest(compression); - ResponseEntity response = client.get().exchange().flatMap((res) -> res.toEntity(Void.class)) + ResponseEntity response = client.get().exchangeToMono(ClientResponse::toBodilessEntity) .block(Duration.ofSeconds(30)); assertResponseIsNotCompressed(response); } @@ -326,8 +323,8 @@ public abstract class AbstractReactiveWebServerFactoryTests { compression.setEnabled(true); compression.setExcludedUserAgents(new String[] { "testUserAgent" }); WebClient client = prepareCompressionTest(compression); - ResponseEntity response = client.get().header("User-Agent", "testUserAgent").exchange() - .flatMap((res) -> res.toEntity(Void.class)).block(Duration.ofSeconds(30)); + ResponseEntity response = client.get().header("User-Agent", "testUserAgent") + .exchangeToMono(ClientResponse::toBodilessEntity).block(Duration.ofSeconds(30)); assertResponseIsNotCompressed(response); } @@ -337,7 +334,7 @@ public abstract class AbstractReactiveWebServerFactoryTests { compression.setEnabled(true); compression.setMimeTypes(new String[] { "application/json" }); WebClient client = prepareCompressionTest(compression, "test~plain"); - ResponseEntity response = client.get().exchange().flatMap((res) -> res.toEntity(Void.class)) + ResponseEntity response = client.get().exchangeToMono(ClientResponse::toBodilessEntity) .block(Duration.ofSeconds(30)); assertResponseIsNotCompressed(response); }