From 4262aab446e12abf1cf3c4f60e0624fb6dba7c70 Mon Sep 17 00:00:00 2001 From: dreis2211 Date: Wed, 25 Sep 2019 11:05:51 +0200 Subject: [PATCH] Fix deprecation warnings caused by BodyInserters.fromObject See gh-18349 --- .../reactive/error/DefaultErrorWebExceptionHandler.java | 2 +- .../undertow/UndertowReactiveWebServerFactoryTests.java | 2 +- .../server/AbstractReactiveWebServerFactoryTests.java | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java index 652b19ca7b..fdfc00e8ad 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java @@ -143,7 +143,7 @@ public class DefaultErrorWebExceptionHandler extends AbstractErrorWebExceptionHa boolean includeStackTrace = isIncludeStackTrace(request, MediaType.ALL); Map error = getErrorAttributes(request, includeStackTrace); return ServerResponse.status(getHttpStatus(error)).contentType(MediaType.APPLICATION_JSON) - .body(BodyInserters.fromObject(error)); + .body(BodyInserters.fromValue(error)); } /** 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 dc237447d5..b3b93ae078 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 @@ -118,7 +118,7 @@ class UndertowReactiveWebServerFactoryTests extends AbstractReactiveWebServerFac this.webServer.start(); WebClient client = getWebClient().build(); Mono 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)); assertThat(result.block(Duration.ofSeconds(30))).isEqualTo("Hello World"); File accessLog = new File(accessLogDirectory, expectedFile); 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 90dc8b1b6e..339a4beef8 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 @@ -94,7 +94,7 @@ public abstract class AbstractReactiveWebServerFactoryTests { this.webServer = factory.getWebServer(new EchoHandler()); this.webServer.start(); Mono 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)); assertThat(result.block(Duration.ofSeconds(30))).isEqualTo("Hello World"); assertThat(this.webServer.getPort()).isEqualTo(specificPort); @@ -122,7 +122,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.fromObject("Hello World")).exchange() + .body(BodyInserters.fromValue("Hello World")).exchange() .flatMap((response) -> response.bodyToMono(String.class)); 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()) .clientConnector(clientConnector).build(); Mono 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)); 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()) .clientConnector(clientConnector).build(); Mono 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)); StepVerifier.create(result).expectError(SSLException.class).verify(Duration.ofSeconds(10)); }