Skip to content

Commit ed38ac6

Browse files
committed
Polish "Add idle timeout property for Reactor Netty"
See gh-27371
1 parent cbcd7b9 commit ed38ac6

File tree

4 files changed

+10
-18
lines changed

4 files changed

+10
-18
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,8 +1301,8 @@ public static class Netty {
13011301
private boolean validateHeaders = true;
13021302

13031303
/**
1304-
* IdleTimeout for netty server .If an idletimeout is not specified, this
1305-
* indicates no timeout(infinite).
1304+
* Idle timeout of the Netty channel. When not specified, an infinite timeout is
1305+
* used.
13061306
*/
13071307
private Duration idleTimeout;
13081308

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 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.

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,12 @@ void testCustomizeJettyAccessLog() {
333333
assertThat(jetty.getAccesslog().getIgnorePaths()).containsExactly("/a/path", "/b/path");
334334
}
335335

336+
@Test
337+
void testCustomizeNettyIdleTimeout() {
338+
bind("server.netty.idle-timeout", "10s");
339+
assertThat(this.properties.getNetty().getIdleTimeout()).isEqualTo(Duration.ofSeconds(10));
340+
}
341+
336342
@Test
337343
void tomcatAcceptCountMatchesProtocolDefault() throws Exception {
338344
assertThat(this.properties.getTomcat().getAcceptCount()).isEqualTo(getDefaultProtocol().getAcceptCount());
@@ -535,12 +541,6 @@ void nettyInitialBufferSizeMatchesHttpDecoderSpecDefault() {
535541
.isEqualTo(HttpDecoderSpec.DEFAULT_INITIAL_BUFFER_SIZE);
536542
}
537543

538-
@Test
539-
void testCustomizeNettyIdleTimeout() {
540-
bind("server.netty.idle-timeout", "10s");
541-
assertThat(this.properties.getNetty().getIdleTimeout()).isEqualTo(Duration.ofSeconds(10));
542-
}
543-
544544
private Connector getDefaultConnector() {
545545
return new Connector(TomcatServletWebServerFactory.DEFAULT_PROTOCOL);
546546
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizerTests.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 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,7 +30,6 @@
3030
import reactor.netty.http.server.HttpServer;
3131

3232
import org.springframework.boot.autoconfigure.web.ServerProperties;
33-
import org.springframework.boot.autoconfigure.web.ServerProperties.ForwardHeadersStrategy;
3433
import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
3534
import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory;
3635
import org.springframework.boot.web.embedded.netty.NettyServerCustomizer;
@@ -104,7 +103,6 @@ void forwardHeadersWhenStrategyIsNoneShouldNotConfigureValve() {
104103

105104
@Test
106105
void setConnectionTimeout() {
107-
setServerProperties();
108106
this.serverProperties.getNetty().setConnectionTimeout(Duration.ofSeconds(1));
109107
NettyReactiveWebServerFactory factory = mock(NettyReactiveWebServerFactory.class);
110108
this.customizer.customize(factory);
@@ -113,7 +111,6 @@ void setConnectionTimeout() {
113111

114112
@Test
115113
void setIdleTimeout() {
116-
setServerProperties();
117114
this.serverProperties.getNetty().setIdleTimeout(Duration.ofSeconds(1));
118115
NettyReactiveWebServerFactory factory = mock(NettyReactiveWebServerFactory.class);
119116
this.customizer.customize(factory);
@@ -165,9 +162,4 @@ private void verifyIdleTimeout(NettyReactiveWebServerFactory factory, Duration e
165162
assertThat(idleTimeout).isEqualTo(expected);
166163
}
167164

168-
private void setServerProperties() {
169-
this.serverProperties.setForwardHeadersStrategy(ForwardHeadersStrategy.NONE);
170-
this.serverProperties.setMaxHttpHeaderSize(null);
171-
}
172-
173165
}

0 commit comments

Comments
 (0)