Fix deprecation warnings caused by BodyInserters.fromObject
See gh-18349
This commit is contained in:
parent
eb00ba7470
commit
4262aab446
|
@ -143,7 +143,7 @@ public class DefaultErrorWebExceptionHandler extends AbstractErrorWebExceptionHa
|
||||||
boolean includeStackTrace = isIncludeStackTrace(request, MediaType.ALL);
|
boolean includeStackTrace = isIncludeStackTrace(request, MediaType.ALL);
|
||||||
Map<String, Object> error = getErrorAttributes(request, includeStackTrace);
|
Map<String, Object> error = getErrorAttributes(request, includeStackTrace);
|
||||||
return ServerResponse.status(getHttpStatus(error)).contentType(MediaType.APPLICATION_JSON)
|
return ServerResponse.status(getHttpStatus(error)).contentType(MediaType.APPLICATION_JSON)
|
||||||
.body(BodyInserters.fromObject(error));
|
.body(BodyInserters.fromValue(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -118,7 +118,7 @@ class UndertowReactiveWebServerFactoryTests extends AbstractReactiveWebServerFac
|
||||||
this.webServer.start();
|
this.webServer.start();
|
||||||
WebClient client = getWebClient().build();
|
WebClient client = getWebClient().build();
|
||||||
Mono<String> result = client.post().uri("/test").contentType(MediaType.TEXT_PLAIN)
|
Mono<String> result = client.post().uri("/test").contentType(MediaType.TEXT_PLAIN)
|
||||||
.body(BodyInserters.fromObject("Hello World")).exchange()
|
.body(BodyInserters.fromValue("Hello World")).exchange()
|
||||||
.flatMap((response) -> response.bodyToMono(String.class));
|
.flatMap((response) -> response.bodyToMono(String.class));
|
||||||
assertThat(result.block(Duration.ofSeconds(30))).isEqualTo("Hello World");
|
assertThat(result.block(Duration.ofSeconds(30))).isEqualTo("Hello World");
|
||||||
File accessLog = new File(accessLogDirectory, expectedFile);
|
File accessLog = new File(accessLogDirectory, expectedFile);
|
||||||
|
|
|
@ -94,7 +94,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
|
||||||
this.webServer = factory.getWebServer(new EchoHandler());
|
this.webServer = factory.getWebServer(new EchoHandler());
|
||||||
this.webServer.start();
|
this.webServer.start();
|
||||||
Mono<String> result = getWebClient().build().post().uri("/test").contentType(MediaType.TEXT_PLAIN)
|
Mono<String> result = getWebClient().build().post().uri("/test").contentType(MediaType.TEXT_PLAIN)
|
||||||
.body(BodyInserters.fromObject("Hello World")).exchange()
|
.body(BodyInserters.fromValue("Hello World")).exchange()
|
||||||
.flatMap((response) -> response.bodyToMono(String.class));
|
.flatMap((response) -> response.bodyToMono(String.class));
|
||||||
assertThat(result.block(Duration.ofSeconds(30))).isEqualTo("Hello World");
|
assertThat(result.block(Duration.ofSeconds(30))).isEqualTo("Hello World");
|
||||||
assertThat(this.webServer.getPort()).isEqualTo(specificPort);
|
assertThat(this.webServer.getPort()).isEqualTo(specificPort);
|
||||||
|
@ -122,7 +122,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
|
||||||
WebClient client = WebClient.builder().baseUrl("https://localhost:" + this.webServer.getPort())
|
WebClient client = WebClient.builder().baseUrl("https://localhost:" + this.webServer.getPort())
|
||||||
.clientConnector(connector).build();
|
.clientConnector(connector).build();
|
||||||
Mono<String> result = client.post().uri("/test").contentType(MediaType.TEXT_PLAIN)
|
Mono<String> result = client.post().uri("/test").contentType(MediaType.TEXT_PLAIN)
|
||||||
.body(BodyInserters.fromObject("Hello World")).exchange()
|
.body(BodyInserters.fromValue("Hello World")).exchange()
|
||||||
.flatMap((response) -> response.bodyToMono(String.class));
|
.flatMap((response) -> response.bodyToMono(String.class));
|
||||||
assertThat(result.block(Duration.ofSeconds(30))).isEqualTo("Hello World");
|
assertThat(result.block(Duration.ofSeconds(30))).isEqualTo("Hello World");
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
|
||||||
WebClient client = WebClient.builder().baseUrl("https://localhost:" + this.webServer.getPort())
|
WebClient client = WebClient.builder().baseUrl("https://localhost:" + this.webServer.getPort())
|
||||||
.clientConnector(clientConnector).build();
|
.clientConnector(clientConnector).build();
|
||||||
Mono<String> result = client.post().uri("/test").contentType(MediaType.TEXT_PLAIN)
|
Mono<String> result = client.post().uri("/test").contentType(MediaType.TEXT_PLAIN)
|
||||||
.body(BodyInserters.fromObject("Hello World")).exchange()
|
.body(BodyInserters.fromValue("Hello World")).exchange()
|
||||||
.flatMap((response) -> response.bodyToMono(String.class));
|
.flatMap((response) -> response.bodyToMono(String.class));
|
||||||
assertThat(result.block(Duration.ofSeconds(30))).isEqualTo("Hello World");
|
assertThat(result.block(Duration.ofSeconds(30))).isEqualTo("Hello World");
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
|
||||||
WebClient client = WebClient.builder().baseUrl("https://localhost:" + this.webServer.getPort())
|
WebClient client = WebClient.builder().baseUrl("https://localhost:" + this.webServer.getPort())
|
||||||
.clientConnector(clientConnector).build();
|
.clientConnector(clientConnector).build();
|
||||||
Mono<String> result = client.post().uri("/test").contentType(MediaType.TEXT_PLAIN)
|
Mono<String> result = client.post().uri("/test").contentType(MediaType.TEXT_PLAIN)
|
||||||
.body(BodyInserters.fromObject("Hello World")).exchange()
|
.body(BodyInserters.fromValue("Hello World")).exchange()
|
||||||
.flatMap((response) -> response.bodyToMono(String.class));
|
.flatMap((response) -> response.bodyToMono(String.class));
|
||||||
StepVerifier.create(result).expectError(SSLException.class).verify(Duration.ofSeconds(10));
|
StepVerifier.create(result).expectError(SSLException.class).verify(Duration.ofSeconds(10));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue