From fb1234a22c5c10f81f2a9466a10f5595a8c3a679 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Tue, 4 Aug 2020 13:26:47 +0200 Subject: [PATCH] Upgrade to Reactor 2020.0.0 SNAPSHOTs See gh-22667 --- .../spring-boot-actuator-autoconfigure/build.gradle | 2 +- spring-boot-project/spring-boot-actuator/build.gradle | 2 +- .../reactive/client/MetricsWebClientFilterFunction.java | 7 ++++--- .../web/reactive/WebFluxEndpointIntegrationTests.java | 2 +- spring-boot-project/spring-boot-autoconfigure/build.gradle | 2 +- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- spring-boot-project/spring-boot-docs/build.gradle | 2 +- .../spring-boot-starter-reactor-netty/build.gradle | 2 +- spring-boot-project/spring-boot-test/build.gradle | 2 +- spring-boot-project/spring-boot/build.gradle | 2 +- .../boot/web/embedded/netty/GracefulShutdown.java | 2 +- 11 files changed, 14 insertions(+), 13 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle b/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle index 3898b33774..8a4ebab1a6 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle @@ -58,7 +58,7 @@ dependencies { optional("io.micrometer:micrometer-registry-signalfx") optional("io.micrometer:micrometer-registry-statsd") optional("io.micrometer:micrometer-registry-wavefront") - optional("io.projectreactor.netty:reactor-netty") + optional("io.projectreactor.netty:reactor-netty-http") optional("io.r2dbc:r2dbc-pool") optional("io.r2dbc:r2dbc-spi") optional("jakarta.jms:jakarta.jms-api") diff --git a/spring-boot-project/spring-boot-actuator/build.gradle b/spring-boot-project/spring-boot-actuator/build.gradle index 8545696e91..7bb8fe658e 100644 --- a/spring-boot-project/spring-boot-actuator/build.gradle +++ b/spring-boot-project/spring-boot-actuator/build.gradle @@ -84,7 +84,7 @@ dependencies { testImplementation("org.springframework:spring-test") testImplementation("com.squareup.okhttp3:mockwebserver") - testRuntimeOnly("io.projectreactor.netty:reactor-netty") + testRuntimeOnly("io.projectreactor.netty:reactor-netty-http") testRuntimeOnly("javax.xml.bind:jaxb-api") testRuntimeOnly("org.apache.tomcat.embed:tomcat-embed-el") testRuntimeOnly("org.glassfish.jersey.ext:jersey-spring5") diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/MetricsWebClientFilterFunction.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/MetricsWebClientFilterFunction.java index ad82c6702b..836dd65484 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/MetricsWebClientFilterFunction.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/MetricsWebClientFilterFunction.java @@ -24,6 +24,7 @@ import io.micrometer.core.instrument.Tag; import reactor.core.publisher.Mono; import reactor.core.publisher.SignalType; import reactor.util.context.Context; +import reactor.util.context.ContextView; import org.springframework.boot.actuate.metrics.AutoTimer; import org.springframework.web.reactive.function.client.ClientRequest; @@ -74,12 +75,12 @@ public class MetricsWebClientFilterFunction implements ExchangeFilterFunction { return next.exchange(request); } return next.exchange(request).as((responseMono) -> instrumentResponse(request, responseMono)) - .subscriberContext(this::putStartTime); + .contextWrite(this::putStartTime); } private Mono instrumentResponse(ClientRequest request, Mono responseMono) { final AtomicBoolean responseReceived = new AtomicBoolean(); - return Mono.deferWithContext((ctx) -> responseMono.doOnEach((signal) -> { + return Mono.deferContextual((ctx) -> responseMono.doOnEach((signal) -> { if (signal.isOnNext() || signal.isOnError()) { responseReceived.set(true); Iterable tags = this.tagProvider.tags(request, signal.get(), signal.getThrowable()); @@ -98,7 +99,7 @@ public class MetricsWebClientFilterFunction implements ExchangeFilterFunction { .register(this.meterRegistry).record(System.nanoTime() - startTime, TimeUnit.NANOSECONDS); } - private Long getStartTime(Context context) { + private Long getStartTime(ContextView context) { return context.get(METRICS_WEBCLIENT_START_TIME); } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/reactive/WebFluxEndpointIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/reactive/WebFluxEndpointIntegrationTests.java index 40bae12804..a1a4c9f07f 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/reactive/WebFluxEndpointIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/reactive/WebFluxEndpointIntegrationTests.java @@ -141,7 +141,7 @@ class WebFluxEndpointIntegrationTests @Bean WebFilter webFilter() { - return (exchange, chain) -> chain.filter(exchange).subscriberContext( + return (exchange, chain) -> chain.filter(exchange).contextWrite( ReactiveSecurityContextHolder.withAuthentication(new UsernamePasswordAuthenticationToken("Alice", "secret", Arrays.asList(new SimpleGrantedAuthority("ROLE_ACTUATOR"))))); } diff --git a/spring-boot-project/spring-boot-autoconfigure/build.gradle b/spring-boot-project/spring-boot-autoconfigure/build.gradle index 58265433bc..6be22e43b5 100644 --- a/spring-boot-project/spring-boot-autoconfigure/build.gradle +++ b/spring-boot-project/spring-boot-autoconfigure/build.gradle @@ -29,7 +29,7 @@ dependencies { optional("com.sun.mail:jakarta.mail") optional("de.flapdoodle.embed:de.flapdoodle.embed.mongo") optional("io.lettuce:lettuce-core") - optional("io.projectreactor.netty:reactor-netty") + optional("io.projectreactor.netty:reactor-netty-http") optional("io.r2dbc:r2dbc-spi") optional("io.r2dbc:r2dbc-pool") optional("io.rsocket:rsocket-core") diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index a79f8abba8..4389647874 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1317,7 +1317,7 @@ bom { ] } } - library("Reactor Bom", "2020.0.0-M1") { + library("Reactor Bom", "2020.0.0-SNAPSHOT") { group("io.projectreactor") { imports = [ "reactor-bom" diff --git a/spring-boot-project/spring-boot-docs/build.gradle b/spring-boot-project/spring-boot-docs/build.gradle index a080ef8028..82960047ee 100644 --- a/spring-boot-project/spring-boot-docs/build.gradle +++ b/spring-boot-project/spring-boot-docs/build.gradle @@ -69,7 +69,7 @@ dependencies { implementation(project(path: ":spring-boot-project:spring-boot-test-autoconfigure")) implementation("com.zaxxer:HikariCP") implementation("io.micrometer:micrometer-core") - implementation("io.projectreactor.netty:reactor-netty") + implementation("io.projectreactor.netty:reactor-netty-http") implementation("jakarta.servlet:jakarta.servlet-api") implementation("org.apache.commons:commons-dbcp2") implementation("org.apache.kafka:kafka-streams") diff --git a/spring-boot-project/spring-boot-starters/spring-boot-starter-reactor-netty/build.gradle b/spring-boot-project/spring-boot-starters/spring-boot-starter-reactor-netty/build.gradle index abf74f4b83..9a3b34e2b4 100644 --- a/spring-boot-project/spring-boot-starters/spring-boot-starter-reactor-netty/build.gradle +++ b/spring-boot-project/spring-boot-starters/spring-boot-starter-reactor-netty/build.gradle @@ -5,5 +5,5 @@ plugins { description = "Starter for using Reactor Netty as the embedded reactive HTTP server." dependencies { - api("io.projectreactor.netty:reactor-netty") + api("io.projectreactor.netty:reactor-netty-http") } diff --git a/spring-boot-project/spring-boot-test/build.gradle b/spring-boot-project/spring-boot-test/build.gradle index 778abc5a52..7175e8c390 100644 --- a/spring-boot-project/spring-boot-test/build.gradle +++ b/spring-boot-project/spring-boot-test/build.gradle @@ -14,7 +14,7 @@ dependencies { optional("com.fasterxml.jackson.core:jackson-databind") optional("com.google.code.gson:gson") optional("com.jayway.jsonpath:json-path") - optional("io.projectreactor.netty:reactor-netty") + optional("io.projectreactor.netty:reactor-netty-http") optional("javax.json.bind:javax.json.bind-api") optional("javax.servlet:javax.servlet-api") optional("junit:junit") diff --git a/spring-boot-project/spring-boot/build.gradle b/spring-boot-project/spring-boot/build.gradle index 06f8f6d07c..5a1219a834 100644 --- a/spring-boot-project/spring-boot/build.gradle +++ b/spring-boot-project/spring-boot/build.gradle @@ -25,7 +25,7 @@ dependencies { optional("com.zaxxer:HikariCP") optional("io.netty:netty-tcnative-boringssl-static") optional("io.projectreactor:reactor-tools") - optional("io.projectreactor.netty:reactor-netty") + optional("io.projectreactor.netty:reactor-netty-http") optional("io.rsocket:rsocket-core") optional("io.rsocket:rsocket-transport-netty") optional("io.undertow:undertow-servlet") { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/GracefulShutdown.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/GracefulShutdown.java index c23518cb1f..12a37e2c18 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/GracefulShutdown.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/GracefulShutdown.java @@ -58,7 +58,7 @@ final class GracefulShutdown { private void doShutdown(GracefulShutdownCallback callback, DisposableServer server) { this.shuttingDown = true; try { - server.disposeNow(Duration.ofMillis(Long.MAX_VALUE)); + server.disposeNow(Duration.ofNanos(Long.MAX_VALUE)); logger.info("Graceful shutdown complete"); callback.shutdownComplete(GracefulShutdownResult.IDLE); }