Skip to content

Commit 7548da1

Browse files
committed
Merge pull request #18349 from dreis2211
* gh-18349: Fix deprecation warnings caused by BodyInserters.fromObject Closes gh-18349
2 parents eb00ba7 + 4262aab commit 7548da1

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ protected Mono<ServerResponse> renderErrorResponse(ServerRequest request) {
143143
boolean includeStackTrace = isIncludeStackTrace(request, MediaType.ALL);
144144
Map<String, Object> error = getErrorAttributes(request, includeStackTrace);
145145
return ServerResponse.status(getHttpStatus(error)).contentType(MediaType.APPLICATION_JSON)
146-
.body(BodyInserters.fromObject(error));
146+
.body(BodyInserters.fromValue(error));
147147
}
148148

149149
/**

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactoryTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private void testAccessLog(String prefix, String suffix, String expectedFile)
118118
this.webServer.start();
119119
WebClient client = getWebClient().build();
120120
Mono<String> result = client.post().uri("/test").contentType(MediaType.TEXT_PLAIN)
121-
.body(BodyInserters.fromObject("Hello World")).exchange()
121+
.body(BodyInserters.fromValue("Hello World")).exchange()
122122
.flatMap((response) -> response.bodyToMono(String.class));
123123
assertThat(result.block(Duration.ofSeconds(30))).isEqualTo("Hello World");
124124
File accessLog = new File(accessLogDirectory, expectedFile);

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void specificPort() {
9494
this.webServer = factory.getWebServer(new EchoHandler());
9595
this.webServer.start();
9696
Mono<String> result = getWebClient().build().post().uri("/test").contentType(MediaType.TEXT_PLAIN)
97-
.body(BodyInserters.fromObject("Hello World")).exchange()
97+
.body(BodyInserters.fromValue("Hello World")).exchange()
9898
.flatMap((response) -> response.bodyToMono(String.class));
9999
assertThat(result.block(Duration.ofSeconds(30))).isEqualTo("Hello World");
100100
assertThat(this.webServer.getPort()).isEqualTo(specificPort);
@@ -122,7 +122,7 @@ protected final void testBasicSslWithKeyStore(String keyStore, String keyPasswor
122122
WebClient client = WebClient.builder().baseUrl("https://localhost:" + this.webServer.getPort())
123123
.clientConnector(connector).build();
124124
Mono<String> result = client.post().uri("/test").contentType(MediaType.TEXT_PLAIN)
125-
.body(BodyInserters.fromObject("Hello World")).exchange()
125+
.body(BodyInserters.fromValue("Hello World")).exchange()
126126
.flatMap((response) -> response.bodyToMono(String.class));
127127
assertThat(result.block(Duration.ofSeconds(30))).isEqualTo("Hello World");
128128
}
@@ -176,7 +176,7 @@ protected void testClientAuthSuccess(Ssl sslConfiguration, ReactorClientHttpConn
176176
WebClient client = WebClient.builder().baseUrl("https://localhost:" + this.webServer.getPort())
177177
.clientConnector(clientConnector).build();
178178
Mono<String> result = client.post().uri("/test").contentType(MediaType.TEXT_PLAIN)
179-
.body(BodyInserters.fromObject("Hello World")).exchange()
179+
.body(BodyInserters.fromValue("Hello World")).exchange()
180180
.flatMap((response) -> response.bodyToMono(String.class));
181181
assertThat(result.block(Duration.ofSeconds(30))).isEqualTo("Hello World");
182182
}
@@ -209,7 +209,7 @@ protected void testClientAuthFailure(Ssl sslConfiguration, ReactorClientHttpConn
209209
WebClient client = WebClient.builder().baseUrl("https://localhost:" + this.webServer.getPort())
210210
.clientConnector(clientConnector).build();
211211
Mono<String> result = client.post().uri("/test").contentType(MediaType.TEXT_PLAIN)
212-
.body(BodyInserters.fromObject("Hello World")).exchange()
212+
.body(BodyInserters.fromValue("Hello World")).exchange()
213213
.flatMap((response) -> response.bodyToMono(String.class));
214214
StepVerifier.create(result).expectError(SSLException.class).verify(Duration.ofSeconds(10));
215215
}

0 commit comments

Comments
 (0)