Browse Source

Rename server.jetty.idle-timeout

This commit renames the `server.jetty.idle-timeout` property to
`server.jetty.thread-idle-timeout`, since there are other timeout
properties that are not tied to the threadpool configuration (e.g. the
connection idle timeout).

We might regroup thread-related properties in a dedicated group in the
future, see gh-18620.

Fixes gh-18615
pull/18632/head
Brian Clozel 6 years ago
parent
commit
1529ba14c8
  1. 10
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java
  2. 2
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/JettyWebServerFactoryCustomizer.java
  3. 4
      spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java
  4. 4
      spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyWebServerFactoryCustomizerTests.java

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

@ -956,7 +956,7 @@ public class ServerProperties { @@ -956,7 +956,7 @@ public class ServerProperties {
/**
* Maximum thread idle time.
*/
private Duration idleTimeout = Duration.ofMillis(60000);
private Duration threadIdleTimeout = Duration.ofMillis(60000);
/**
* Time that the connection can be idle before it is closed.
@ -1007,12 +1007,12 @@ public class ServerProperties { @@ -1007,12 +1007,12 @@ public class ServerProperties {
return this.maxThreads;
}
public void setIdleTimeout(Duration idleTimeout) {
this.idleTimeout = idleTimeout;
public void setThreadIdleTimeout(Duration threadIdleTimeout) {
this.threadIdleTimeout = threadIdleTimeout;
}
public Duration getIdleTimeout() {
return this.idleTimeout;
public Duration getThreadIdleTimeout() {
return this.threadIdleTimeout;
}
public Duration getConnectionIdleTimeout() {

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

@ -86,7 +86,7 @@ public class JettyWebServerFactoryCustomizer @@ -86,7 +86,7 @@ public class JettyWebServerFactoryCustomizer
.to((maxThreads) -> customizeThreadPool(factory, (threadPool) -> threadPool.setMaxThreads(maxThreads)));
propertyMapper.from(jettyProperties::getMinThreads).when(this::isPositive)
.to((minThreads) -> customizeThreadPool(factory, (threadPool) -> threadPool.setMinThreads(minThreads)));
propertyMapper.from(jettyProperties::getIdleTimeout).whenNonNull().asInt(Duration::toMillis).to(
propertyMapper.from(jettyProperties::getThreadIdleTimeout).whenNonNull().asInt(Duration::toMillis).to(
(idleTimeout) -> customizeThreadPool(factory, (threadPool) -> threadPool.setIdleTimeout(idleTimeout)));
propertyMapper.from(properties::getConnectionTimeout).whenNonNull()
.to((connectionTimeout) -> customizeIdleTimeout(factory, connectionTimeout));

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

@ -233,8 +233,8 @@ class ServerPropertiesTests { @@ -233,8 +233,8 @@ class ServerPropertiesTests {
@Test
void testCustomizeJettyIdleTimeout() {
bind("server.jetty.idle-timeout", "10s");
assertThat(this.properties.getJetty().getIdleTimeout()).isEqualTo(Duration.ofSeconds(10));
bind("server.jetty.thread-idle-timeout", "10s");
assertThat(this.properties.getJetty().getThreadIdleTimeout()).isEqualTo(Duration.ofSeconds(10));
}
@Test

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

@ -134,8 +134,8 @@ class JettyWebServerFactoryCustomizerTests { @@ -134,8 +134,8 @@ class JettyWebServerFactoryCustomizerTests {
}
@Test
void idleTimeoutCanBeCustomized() {
bind("server.jetty.idle-timeout=100s");
void threadIdleTimeoutCanBeCustomized() {
bind("server.jetty.thread-idle-timeout=100s");
JettyWebServer server = customizeAndGetServer();
QueuedThreadPool threadPool = (QueuedThreadPool) server.getServer().getThreadPool();
assertThat(threadPool.getIdleTimeout()).isEqualTo(100000);

Loading…
Cancel
Save