From 47993c094bbb1ba787e7c6d2561a228976af84c7 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 8 Jul 2022 10:59:02 +0100 Subject: [PATCH] Start building against Reactor 2022.0.0-M4 snapshots See gh-31609 --- .../redis/LettuceConnectionConfiguration.java | 17 ++++++++++++++++- .../autoconfigure/web/ServerProperties.java | 4 ++++ .../NettyWebServerFactoryCustomizer.java | 11 +++++++++-- .../web/ServerPropertiesTests.java | 1 + .../NettyWebServerFactoryCustomizerTests.java | 14 ++++++++++++-- .../spring-boot-dependencies/build.gradle | 2 +- 6 files changed, 43 insertions(+), 6 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/LettuceConnectionConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/LettuceConnectionConfiguration.java index 9d7f20cb3d7..2c204608f82 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/LettuceConnectionConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/LettuceConnectionConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,9 +25,12 @@ import io.lettuce.core.TimeoutOptions; import io.lettuce.core.cluster.ClusterClientOptions; import io.lettuce.core.cluster.ClusterTopologyRefreshOptions; import io.lettuce.core.cluster.ClusterTopologyRefreshOptions.Builder; +import io.lettuce.core.event.Event; +import io.lettuce.core.event.EventBus; import io.lettuce.core.resource.ClientResources; import io.lettuce.core.resource.DefaultClientResources; import org.apache.commons.pool2.impl.GenericObjectPoolConfig; +import reactor.core.publisher.Flux; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; @@ -69,6 +72,18 @@ class LettuceConnectionConfiguration extends RedisConnectionConfiguration { @ConditionalOnMissingBean(ClientResources.class) DefaultClientResources lettuceClientResources(ObjectProvider customizers) { DefaultClientResources.Builder builder = DefaultClientResources.builder(); + builder.eventBus(new EventBus() { + + @Override + public Flux get() { + return Flux.empty(); + } + + @Override + public void publish(Event event) { + } + + }); customizers.orderedStream().forEach((customizer) -> customizer.customize(builder)); return builder.build(); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java index 570464db5bb..2a0333d0bbb 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java @@ -31,6 +31,7 @@ import java.util.Map; import io.undertow.UndertowOptions; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; import org.springframework.boot.context.properties.NestedConfigurationProperty; import org.springframework.boot.convert.DurationUnit; import org.springframework.boot.web.server.Compression; @@ -1384,10 +1385,13 @@ public class ServerProperties { this.initialBufferSize = initialBufferSize; } + @Deprecated + @DeprecatedConfigurationProperty(reason = "Deprecated for removal in Reactor Netty") public DataSize getMaxChunkSize() { return this.maxChunkSize; } + @Deprecated public void setMaxChunkSize(DataSize maxChunkSize) { this.maxChunkSize = maxChunkSize; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizer.java index 1776b8c97b4..382ef4bf2bf 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizer.java @@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.web.embedded; import java.time.Duration; import io.netty.channel.ChannelOption; +import reactor.netty.http.server.HttpRequestDecoderSpec; import org.springframework.boot.autoconfigure.web.ServerProperties; import org.springframework.boot.cloud.CloudPlatform; @@ -86,8 +87,7 @@ public class NettyWebServerFactoryCustomizer .to((maxHttpRequestHeader) -> httpRequestDecoderSpec .maxHeaderSize((int) maxHttpRequestHeader.toBytes())); ServerProperties.Netty nettyProperties = this.serverProperties.getNetty(); - propertyMapper.from(nettyProperties.getMaxChunkSize()).whenNonNull() - .to((maxChunkSize) -> httpRequestDecoderSpec.maxChunkSize((int) maxChunkSize.toBytes())); + maxChunkSize(propertyMapper, httpRequestDecoderSpec, nettyProperties); propertyMapper.from(nettyProperties.getMaxInitialLineLength()).whenNonNull() .to((maxInitialLineLength) -> httpRequestDecoderSpec .maxInitialLineLength((int) maxInitialLineLength.toBytes())); @@ -102,6 +102,13 @@ public class NettyWebServerFactoryCustomizer })); } + @SuppressWarnings("deprecation") + private void maxChunkSize(PropertyMapper propertyMapper, HttpRequestDecoderSpec httpRequestDecoderSpec, + ServerProperties.Netty nettyProperties) { + propertyMapper.from(nettyProperties.getMaxChunkSize()).whenNonNull() + .to((maxChunkSize) -> httpRequestDecoderSpec.maxChunkSize((int) maxChunkSize.toBytes())); + } + private void customizeIdleTimeout(NettyReactiveWebServerFactory factory, Duration idleTimeout) { factory.addServerCustomizers((httpServer) -> httpServer.idleTimeout(idleTimeout)); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java index 887869f5429..3e12fd07588 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java @@ -514,6 +514,7 @@ class ServerPropertiesTests { } @Test + @SuppressWarnings("deprecation") void nettyMaxChunkSizeMatchesHttpDecoderSpecDefault() { assertThat(this.properties.getNetty().getMaxChunkSize().toBytes()) .isEqualTo(HttpDecoderSpec.DEFAULT_MAX_CHUNK_SIZE); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizerTests.java index dbb9785edc7..696dc5bf10b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizerTests.java @@ -132,7 +132,7 @@ class NettyWebServerFactoryCustomizerTests { nettyProperties.setValidateHeaders(false); nettyProperties.setInitialBufferSize(DataSize.ofBytes(512)); nettyProperties.setH2cMaxContentLength(DataSize.ofKilobytes(1)); - nettyProperties.setMaxChunkSize(DataSize.ofKilobytes(16)); + setMaxChunkSize(nettyProperties); nettyProperties.setMaxInitialLineLength(DataSize.ofKilobytes(32)); NettyReactiveWebServerFactory factory = mock(NettyReactiveWebServerFactory.class); this.customizer.customize(factory); @@ -143,10 +143,20 @@ class NettyWebServerFactoryCustomizerTests { assertThat(decoder.validateHeaders()).isFalse(); assertThat(decoder.initialBufferSize()).isEqualTo(nettyProperties.getInitialBufferSize().toBytes()); assertThat(decoder.h2cMaxContentLength()).isEqualTo(nettyProperties.getH2cMaxContentLength().toBytes()); - assertThat(decoder.maxChunkSize()).isEqualTo(nettyProperties.getMaxChunkSize().toBytes()); + assertMaxChunkSize(nettyProperties, decoder); assertThat(decoder.maxInitialLineLength()).isEqualTo(nettyProperties.getMaxInitialLineLength().toBytes()); } + @SuppressWarnings("deprecation") + private void setMaxChunkSize(ServerProperties.Netty nettyProperties) { + nettyProperties.setMaxChunkSize(DataSize.ofKilobytes(16)); + } + + @SuppressWarnings("deprecation") + private void assertMaxChunkSize(ServerProperties.Netty nettyProperties, HttpRequestDecoderSpec decoder) { + assertThat(decoder.maxChunkSize()).isEqualTo(nettyProperties.getMaxChunkSize().toBytes()); + } + private void verifyConnectionTimeout(NettyReactiveWebServerFactory factory, Integer expected) { if (expected == null) { then(factory).should(never()).addServerCustomizers(any(NettyServerCustomizer.class)); diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index ad95c4ff849..43f9dacc576 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1188,7 +1188,7 @@ bom { ] } } - library("Reactor Bom", "2022.0.0-M2") { + library("Reactor Bom", "2022.0.0-SNAPSHOT") { group("io.projectreactor") { imports = [ "reactor-bom"