JAVA-29183 :- Upgrade spring-5-webflux & spring-5-webflux-2 to Spring Boot 3. (#16149)

Co-authored-by: Amit Pandey <amitpandey@cloud.upwork.com>
This commit is contained in:
Amit Pandey 2024-04-01 15:30:57 +05:30 committed by GitHub
parent ff723063a7
commit 25217a11bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 36 additions and 63 deletions

View File

@ -10,30 +10,11 @@
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-boot-2</artifactId>
<artifactId>parent-boot-3</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-boot-2</relativePath>
<relativePath>../parent-boot-3</relativePath>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit-jupiter.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
@ -110,14 +91,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>16</source>
<target>16</target>
</configuration>
</plugin>
</plugins>
</build>
@ -126,6 +99,9 @@
<caffeine.version>3.1.8</caffeine.version>
<testcontainers-mongodb.version>1.16.2</testcontainers-mongodb.version>
<mockwebserver.version>5.0.0-alpha.12</mockwebserver.version>
<spring-boot.repackage.skip>true</spring-boot.repackage.skip>
<spring-boot.version>3.2.2</spring-boot.version>
<junit-jupiter.version>5.10.2</junit-jupiter.version>
</properties>
</project>

View File

@ -1,12 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="Console"
class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%C{1.}): %msg%n%throwable
</Pattern>
</layout>
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg %kvp%n</pattern>
</encoder>
</appender>
<appender name="AccessLog" class="ch.qos.logback.core.FileAppender">

View File

@ -1,12 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%C{1.}): %msg%n%throwable
</Pattern>
</layout>
</appender>
<root level="info">
<appender-ref ref="Console"/>
</root>

View File

@ -10,9 +10,9 @@
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-boot-2</artifactId>
<artifactId>parent-boot-3</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-boot-2</relativePath>
<relativePath>../parent-boot-3</relativePath>
</parent>
<dependencyManagement>
@ -90,12 +90,22 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<parameters>true</parameters>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<mockwebserver.version>5.0.0-alpha.12</mockwebserver.version>
<kotlin-stdlib.version>2.0.0-Beta4</kotlin-stdlib.version>
<spring-boot.repackage.skip>true</spring-boot.repackage.skip>
<spring-boot.version>3.2.2</spring-boot.version>
<junit-jupiter.version>5.10.2</junit-jupiter.version>
</properties>
</project>

View File

@ -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<String> 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<String> noContent() {
return Flux.empty();
}
@GetMapping(value = "/accepted", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@GetMapping(value = "/accepted", produces = MediaType.APPLICATION_JSON_VALUE)
public Flux<String> accepted(ServerHttpResponse response) {
response.setStatusCode(HttpStatus.ACCEPTED);
return Flux.just("accepted");

View File

@ -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)

View File

@ -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);
}
}

View File

@ -14,7 +14,7 @@ public class TimeoutController {
@GetMapping("/{timeout}")
private Mono<String> timeout(@PathVariable int timeout) {
try {
Thread.sleep(timeout * 1000);
Thread.sleep(timeout * 1000L);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}

View File

@ -1,12 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="Console"
class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%C{1.}): %msg%n%throwable
</Pattern>
</layout>
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg %kvp%n</pattern>
</encoder>
</appender>
<appender name="AccessLog" class="ch.qos.logback.core.FileAppender">

View File

@ -1,12 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%C{1.}): %msg%n%throwable
</Pattern>
</layout>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg %kvp%n</pattern>
</encoder>
</appender>
<root level="info">
<appender-ref ref="Console"/>
</root>