mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Start building against Reactor 2022.0.0-M4 snapshots again
See gh-31609
This commit is contained in:
parent
a5b178657f
commit
03ec079040
@ -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<ClientResourcesBuilderCustomizer> customizers) {
|
||||
DefaultClientResources.Builder builder = DefaultClientResources.builder();
|
||||
builder.eventBus(new EventBus() {
|
||||
|
||||
@Override
|
||||
public Flux<Event> get() {
|
||||
return Flux.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publish(Event event) {
|
||||
}
|
||||
|
||||
});
|
||||
customizers.orderedStream().forEach((customizer) -> customizer.customize(builder));
|
||||
return builder.build();
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -514,6 +514,7 @@ class ServerPropertiesTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void nettyMaxChunkSizeMatchesHttpDecoderSpecDefault() {
|
||||
assertThat(this.properties.getNetty().getMaxChunkSize().toBytes())
|
||||
.isEqualTo(HttpDecoderSpec.DEFAULT_MAX_CHUNK_SIZE);
|
||||
|
@ -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));
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user