Skip to content

Commit b28369d

Browse files
committed
Merge branch '2.7.x' into 3.0.x
Closes gh-34036
2 parents fd1b596 + 66e1905 commit b28369d

File tree

8 files changed

+133
-23
lines changed

8 files changed

+133
-23
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright 2012-2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.autoconfigure.reactor.netty;
18+
19+
import java.time.Duration;
20+
21+
import org.springframework.boot.context.properties.ConfigurationProperties;
22+
23+
/**
24+
* Configuration properties for Reactor Netty configuration.
25+
*
26+
* @author Moritz Halbritter
27+
* @since 2.7.9
28+
*/
29+
@ConfigurationProperties(prefix = "spring.reactor.netty")
30+
public class ReactorNettyConfigurationProperties {
31+
32+
/**
33+
* Configure the amount of time to wait before shutting down resources.
34+
*/
35+
private Duration shutdownQuietPeriod;
36+
37+
public Duration getShutdownQuietPeriod() {
38+
return this.shutdownQuietPeriod;
39+
}
40+
41+
public void setShutdownQuietPeriod(Duration shutdownQuietPeriod) {
42+
this.shutdownQuietPeriod = shutdownQuietPeriod;
43+
}
44+
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2012-2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.autoconfigure.reactor.netty;
18+
19+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
20+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
21+
import org.springframework.context.annotation.Bean;
22+
import org.springframework.context.annotation.Configuration;
23+
import org.springframework.http.client.reactive.ReactorResourceFactory;
24+
25+
/**
26+
* Configurations for Reactor Netty. Those should be {@code @Import} in a regular
27+
* auto-configuration class.
28+
*
29+
* @author Moritz Halbritter
30+
* @since 2.7.9
31+
*/
32+
public final class ReactorNettyConfigurations {
33+
34+
private ReactorNettyConfigurations() {
35+
}
36+
37+
@Configuration(proxyBeanMethods = false)
38+
@EnableConfigurationProperties(ReactorNettyConfigurationProperties.class)
39+
public static class ReactorResourceFactoryConfiguration {
40+
41+
@Bean
42+
@ConditionalOnMissingBean
43+
ReactorResourceFactory reactorResourceFactory(ReactorNettyConfigurationProperties configurationProperties) {
44+
ReactorResourceFactory reactorResourceFactory = new ReactorResourceFactory();
45+
if (configurationProperties.getShutdownQuietPeriod() != null) {
46+
reactorResourceFactory.setShutdownQuietPeriod(configurationProperties.getShutdownQuietPeriod());
47+
}
48+
return reactorResourceFactory;
49+
}
50+
51+
}
52+
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2012-2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* Auto-configuration for Reactor Netty.
19+
*/
20+
package org.springframework.boot.autoconfigure.reactor.netty;

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketServerAutoConfiguration.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@
3030
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
3131
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
3232
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
33+
import org.springframework.boot.autoconfigure.reactor.netty.ReactorNettyConfigurations;
3334
import org.springframework.boot.context.properties.EnableConfigurationProperties;
3435
import org.springframework.boot.context.properties.PropertyMapper;
3536
import org.springframework.boot.rsocket.context.RSocketServerBootstrap;
@@ -39,6 +40,7 @@
3940
import org.springframework.context.annotation.Bean;
4041
import org.springframework.context.annotation.Conditional;
4142
import org.springframework.context.annotation.Configuration;
43+
import org.springframework.context.annotation.Import;
4244
import org.springframework.core.io.buffer.NettyDataBufferFactory;
4345
import org.springframework.http.client.reactive.ReactorResourceFactory;
4446
import org.springframework.messaging.rsocket.RSocketStrategies;
@@ -77,14 +79,9 @@ RSocketWebSocketNettyRouteProvider rSocketWebsocketRouteProvider(RSocketProperti
7779
@ConditionalOnProperty(prefix = "spring.rsocket.server", name = "port")
7880
@ConditionalOnClass(ReactorResourceFactory.class)
7981
@Configuration(proxyBeanMethods = false)
82+
@Import(ReactorNettyConfigurations.ReactorResourceFactoryConfiguration.class)
8083
static class EmbeddedServerConfiguration {
8184

82-
@Bean
83-
@ConditionalOnMissingBean
84-
ReactorResourceFactory reactorResourceFactory() {
85-
return new ReactorResourceFactory();
86-
}
87-
8885
@Bean
8986
@ConditionalOnMissingBean
9087
RSocketServerFactory rSocketServerFactory(RSocketProperties properties, ReactorResourceFactory resourceFactory,

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryConfiguration.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
2323
import org.springframework.beans.factory.ObjectProvider;
2424
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
2525
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
26+
import org.springframework.boot.autoconfigure.reactor.netty.ReactorNettyConfigurations;
2627
import org.springframework.boot.web.embedded.jetty.JettyReactiveWebServerFactory;
2728
import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer;
2829
import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory;
@@ -37,6 +38,7 @@
3738
import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
3839
import org.springframework.context.annotation.Bean;
3940
import org.springframework.context.annotation.Configuration;
41+
import org.springframework.context.annotation.Import;
4042
import org.springframework.http.client.reactive.JettyResourceFactory;
4143
import org.springframework.http.client.reactive.ReactorResourceFactory;
4244

@@ -55,14 +57,9 @@ abstract class ReactiveWebServerFactoryConfiguration {
5557
@Configuration(proxyBeanMethods = false)
5658
@ConditionalOnMissingBean(ReactiveWebServerFactory.class)
5759
@ConditionalOnClass({ HttpServer.class })
60+
@Import(ReactorNettyConfigurations.ReactorResourceFactoryConfiguration.class)
5861
static class EmbeddedNetty {
5962

60-
@Bean
61-
@ConditionalOnMissingBean
62-
ReactorResourceFactory reactorServerResourceFactory() {
63-
return new ReactorResourceFactory();
64-
}
65-
6663
@Bean
6764
NettyReactiveWebServerFactory nettyReactiveWebServerFactory(ReactorResourceFactory resourceFactory,
6865
ObjectProvider<NettyRouteProvider> routes, ObjectProvider<NettyServerCustomizer> serverCustomizers) {

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/function/client/ClientHttpConnectorConfiguration.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,8 +26,10 @@
2626
import org.springframework.beans.factory.ObjectProvider;
2727
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
2828
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
29+
import org.springframework.boot.autoconfigure.reactor.netty.ReactorNettyConfigurations;
2930
import org.springframework.context.annotation.Bean;
3031
import org.springframework.context.annotation.Configuration;
32+
import org.springframework.context.annotation.Import;
3133
import org.springframework.context.annotation.Lazy;
3234
import org.springframework.http.client.reactive.ClientHttpConnector;
3335
import org.springframework.http.client.reactive.HttpComponentsClientHttpConnector;
@@ -51,14 +53,9 @@ class ClientHttpConnectorConfiguration {
5153
@Configuration(proxyBeanMethods = false)
5254
@ConditionalOnClass(reactor.netty.http.client.HttpClient.class)
5355
@ConditionalOnMissingBean(ClientHttpConnector.class)
56+
@Import(ReactorNettyConfigurations.ReactorResourceFactoryConfiguration.class)
5457
static class ReactorNetty {
5558

56-
@Bean
57-
@ConditionalOnMissingBean
58-
ReactorResourceFactory reactorClientResourceFactory() {
59-
return new ReactorResourceFactory();
60-
}
61-
6259
@Bean
6360
@Lazy
6461
ReactorClientHttpConnector reactorClientHttpConnector(ReactorResourceFactory reactorResourceFactory,

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/ClientHttpConnectorAutoConfigurationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@ void whenReactorIsAvailableThenReactorBeansAreDefined() {
5757
BeanDefinition connectorDefinition = context.getBeanFactory()
5858
.getBeanDefinition("reactorClientHttpConnector");
5959
assertThat(connectorDefinition.isLazyInit()).isTrue();
60-
assertThat(context).hasBean("reactorClientResourceFactory");
60+
assertThat(context).hasSingleBean(ReactorResourceFactory.class);
6161
});
6262
}
6363

spring-boot-project/spring-boot-devtools/src/main/resources/org/springframework/boot/devtools/env/devtools-property-defaults.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ spring.template.provider.cache=false
1313
spring.thymeleaf.cache=false
1414
spring.web.resources.cache.period=0
1515
spring.web.resources.chain.cache=false
16+
spring.reactor.netty.shutdown-quiet-period=0s

0 commit comments

Comments
 (0)