From 25217a11bda7ec83e6b5f39c22cde0fb6a8ce91b Mon Sep 17 00:00:00 2001 From: Amit Pandey Date: Mon, 1 Apr 2024 15:30:57 +0530 Subject: [PATCH] JAVA-29183 :- Upgrade spring-5-webflux & spring-5-webflux-2 to Spring Boot 3. (#16149) Co-authored-by: Amit Pandey --- spring-5-webflux-2/pom.xml | 34 +++---------------- .../src/main/resources/logback.xml | 11 +++--- .../src/test/resources/logback-test.xml | 7 ---- spring-5-webflux/pom.xml | 14 ++++++-- .../ResponseStatusController.java | 6 ++-- .../spring/retry/ExternalConnector.java | 3 +- .../NettyWebServerFactorySslCustomizer.java | 2 +- .../serverconfig/TimeoutController.java | 2 +- .../src/main/resources/logback.xml | 11 +++--- .../src/test/resources/logback-test.xml | 9 +++-- 10 files changed, 36 insertions(+), 63 deletions(-) diff --git a/spring-5-webflux-2/pom.xml b/spring-5-webflux-2/pom.xml index 38cbbc8bf0..2bc981f9db 100644 --- a/spring-5-webflux-2/pom.xml +++ b/spring-5-webflux-2/pom.xml @@ -10,30 +10,11 @@ com.baeldung - parent-boot-2 + parent-boot-3 0.0.1-SNAPSHOT - ../parent-boot-2 + ../parent-boot-3 - - - - org.junit - junit-bom - ${junit-jupiter.version} - pom - import - - - org.springframework.boot - spring-boot-dependencies - ${spring-boot.version} - pom - import - - - - org.springframework.boot @@ -110,14 +91,6 @@ org.springframework.boot spring-boot-maven-plugin - - org.apache.maven.plugins - maven-compiler-plugin - - 16 - 16 - - @@ -126,6 +99,9 @@ 3.1.8 1.16.2 5.0.0-alpha.12 + true + 3.2.2 + 5.10.2 \ No newline at end of file diff --git a/spring-5-webflux-2/src/main/resources/logback.xml b/spring-5-webflux-2/src/main/resources/logback.xml index 48b68c6bf1..a81845477f 100644 --- a/spring-5-webflux-2/src/main/resources/logback.xml +++ b/spring-5-webflux-2/src/main/resources/logback.xml @@ -1,12 +1,9 @@ - - - - %black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%C{1.}): %msg%n%throwable - - + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg %kvp%n + diff --git a/spring-5-webflux-2/src/test/resources/logback-test.xml b/spring-5-webflux-2/src/test/resources/logback-test.xml index 12cedf5952..254798dc62 100644 --- a/spring-5-webflux-2/src/test/resources/logback-test.xml +++ b/spring-5-webflux-2/src/test/resources/logback-test.xml @@ -1,12 +1,5 @@ - - - - %black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%C{1.}): %msg%n%throwable - - - diff --git a/spring-5-webflux/pom.xml b/spring-5-webflux/pom.xml index 62a463a5cd..f0de0e5dcb 100644 --- a/spring-5-webflux/pom.xml +++ b/spring-5-webflux/pom.xml @@ -10,9 +10,9 @@ com.baeldung - parent-boot-2 + parent-boot-3 0.0.1-SNAPSHOT - ../parent-boot-2 + ../parent-boot-3 @@ -90,12 +90,22 @@ org.springframework.boot spring-boot-maven-plugin + + org.apache.maven.plugins + maven-compiler-plugin + + true + + 5.0.0-alpha.12 2.0.0-Beta4 + true + 3.2.2 + 5.10.2 \ No newline at end of file diff --git a/spring-5-webflux/src/main/java/com/baeldung/spring/responsestatus/ResponseStatusController.java b/spring-5-webflux/src/main/java/com/baeldung/spring/responsestatus/ResponseStatusController.java index bc4f628ab1..121608e7c2 100644 --- a/spring-5-webflux/src/main/java/com/baeldung/spring/responsestatus/ResponseStatusController.java +++ b/spring-5-webflux/src/main/java/com/baeldung/spring/responsestatus/ResponseStatusController.java @@ -18,18 +18,18 @@ import static org.springframework.web.reactive.function.server.RequestPredicates @RestController public class ResponseStatusController { - @GetMapping(value = "/ok", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @GetMapping(value = "/ok", produces = MediaType.APPLICATION_JSON_VALUE) public Flux ok() { return Flux.just("ok"); } - @GetMapping(value = "/no-content", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @GetMapping(value = "/no-content", produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.NO_CONTENT) public Flux noContent() { return Flux.empty(); } - @GetMapping(value = "/accepted", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @GetMapping(value = "/accepted", produces = MediaType.APPLICATION_JSON_VALUE) public Flux accepted(ServerHttpResponse response) { response.setStatusCode(HttpStatus.ACCEPTED); return Flux.just("accepted"); diff --git a/spring-5-webflux/src/main/java/com/baeldung/spring/retry/ExternalConnector.java b/spring-5-webflux/src/main/java/com/baeldung/spring/retry/ExternalConnector.java index baace095a7..597831b7e6 100644 --- a/spring-5-webflux/src/main/java/com/baeldung/spring/retry/ExternalConnector.java +++ b/spring-5-webflux/src/main/java/com/baeldung/spring/retry/ExternalConnector.java @@ -3,6 +3,7 @@ package com.baeldung.spring.retry; import java.time.Duration; import org.springframework.http.HttpStatus; +import org.springframework.http.HttpStatusCode; import org.springframework.http.MediaType; import org.springframework.stereotype.Component; import org.springframework.web.reactive.function.client.WebClient; @@ -24,7 +25,7 @@ public class ExternalConnector { .uri(PATH_BY_ID, stockId) .accept(MediaType.APPLICATION_JSON) .retrieve() - .onStatus(HttpStatus::is5xxServerError, response -> Mono.error(new ServiceException("Server error", response.rawStatusCode()))) + .onStatus(HttpStatusCode::is5xxServerError, response -> Mono.error(new ServiceException("Server error", response.statusCode().value()))) .bodyToMono(String.class) .retryWhen(Retry.backoff(3, Duration.ofSeconds(2)) .filter(throwable -> throwable instanceof ServiceException) diff --git a/spring-5-webflux/src/main/java/com/baeldung/spring/serverconfig/NettyWebServerFactorySslCustomizer.java b/spring-5-webflux/src/main/java/com/baeldung/spring/serverconfig/NettyWebServerFactorySslCustomizer.java index cf4e5ac8ea..9ee722cb55 100644 --- a/spring-5-webflux/src/main/java/com/baeldung/spring/serverconfig/NettyWebServerFactorySslCustomizer.java +++ b/spring-5-webflux/src/main/java/com/baeldung/spring/serverconfig/NettyWebServerFactorySslCustomizer.java @@ -20,7 +20,7 @@ public class NettyWebServerFactorySslCustomizer implements WebServerFactoryCusto ssl.setKeyStorePassword("secret"); Http2 http2 = new Http2(); http2.setEnabled(false); - serverFactory.addServerCustomizers(new SslServerCustomizer(ssl, http2, null)); + serverFactory.addServerCustomizers(new SslServerCustomizer(http2, ssl.getClientAuth(), null)); serverFactory.setPort(8443); } } diff --git a/spring-5-webflux/src/main/java/com/baeldung/spring/serverconfig/TimeoutController.java b/spring-5-webflux/src/main/java/com/baeldung/spring/serverconfig/TimeoutController.java index a4cd6bd6ba..3f0c004d6c 100644 --- a/spring-5-webflux/src/main/java/com/baeldung/spring/serverconfig/TimeoutController.java +++ b/spring-5-webflux/src/main/java/com/baeldung/spring/serverconfig/TimeoutController.java @@ -14,7 +14,7 @@ public class TimeoutController { @GetMapping("/{timeout}") private Mono timeout(@PathVariable int timeout) { try { - Thread.sleep(timeout * 1000); + Thread.sleep(timeout * 1000L); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } diff --git a/spring-5-webflux/src/main/resources/logback.xml b/spring-5-webflux/src/main/resources/logback.xml index 48b68c6bf1..a81845477f 100644 --- a/spring-5-webflux/src/main/resources/logback.xml +++ b/spring-5-webflux/src/main/resources/logback.xml @@ -1,12 +1,9 @@ - - - - %black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%C{1.}): %msg%n%throwable - - + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg %kvp%n + diff --git a/spring-5-webflux/src/test/resources/logback-test.xml b/spring-5-webflux/src/test/resources/logback-test.xml index 12cedf5952..c1df08bdb5 100644 --- a/spring-5-webflux/src/test/resources/logback-test.xml +++ b/spring-5-webflux/src/test/resources/logback-test.xml @@ -1,12 +1,11 @@ - - - %black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%C{1.}): %msg%n%throwable - - + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg %kvp%n + +