Polish "Add idle timeout property for Reactor Netty"
See gh-27371
This commit is contained in:
parent
cbcd7b939b
commit
ed38ac6ff0
|
|
@ -1301,8 +1301,8 @@ public class ServerProperties {
|
|||
private boolean validateHeaders = true;
|
||||
|
||||
/**
|
||||
* IdleTimeout for netty server .If an idletimeout is not specified, this
|
||||
* indicates no timeout(infinite).
|
||||
* Idle timeout of the Netty channel. When not specified, an infinite timeout is
|
||||
* used.
|
||||
*/
|
||||
private Duration idleTimeout;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
|
|
|
|||
|
|
@ -333,6 +333,12 @@ class ServerPropertiesTests {
|
|||
assertThat(jetty.getAccesslog().getIgnorePaths()).containsExactly("/a/path", "/b/path");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomizeNettyIdleTimeout() {
|
||||
bind("server.netty.idle-timeout", "10s");
|
||||
assertThat(this.properties.getNetty().getIdleTimeout()).isEqualTo(Duration.ofSeconds(10));
|
||||
}
|
||||
|
||||
@Test
|
||||
void tomcatAcceptCountMatchesProtocolDefault() throws Exception {
|
||||
assertThat(this.properties.getTomcat().getAcceptCount()).isEqualTo(getDefaultProtocol().getAcceptCount());
|
||||
|
|
@ -535,12 +541,6 @@ class ServerPropertiesTests {
|
|||
.isEqualTo(HttpDecoderSpec.DEFAULT_INITIAL_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomizeNettyIdleTimeout() {
|
||||
bind("server.netty.idle-timeout", "10s");
|
||||
assertThat(this.properties.getNetty().getIdleTimeout()).isEqualTo(Duration.ofSeconds(10));
|
||||
}
|
||||
|
||||
private Connector getDefaultConnector() {
|
||||
return new Connector(TomcatServletWebServerFactory.DEFAULT_PROTOCOL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
|
|
@ -30,7 +30,6 @@ import reactor.netty.http.server.HttpRequestDecoderSpec;
|
|||
import reactor.netty.http.server.HttpServer;
|
||||
|
||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||
import org.springframework.boot.autoconfigure.web.ServerProperties.ForwardHeadersStrategy;
|
||||
import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
|
||||
import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory;
|
||||
import org.springframework.boot.web.embedded.netty.NettyServerCustomizer;
|
||||
|
|
@ -104,7 +103,6 @@ class NettyWebServerFactoryCustomizerTests {
|
|||
|
||||
@Test
|
||||
void setConnectionTimeout() {
|
||||
setServerProperties();
|
||||
this.serverProperties.getNetty().setConnectionTimeout(Duration.ofSeconds(1));
|
||||
NettyReactiveWebServerFactory factory = mock(NettyReactiveWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
|
|
@ -113,7 +111,6 @@ class NettyWebServerFactoryCustomizerTests {
|
|||
|
||||
@Test
|
||||
void setIdleTimeout() {
|
||||
setServerProperties();
|
||||
this.serverProperties.getNetty().setIdleTimeout(Duration.ofSeconds(1));
|
||||
NettyReactiveWebServerFactory factory = mock(NettyReactiveWebServerFactory.class);
|
||||
this.customizer.customize(factory);
|
||||
|
|
@ -165,9 +162,4 @@ class NettyWebServerFactoryCustomizerTests {
|
|||
assertThat(idleTimeout).isEqualTo(expected);
|
||||
}
|
||||
|
||||
private void setServerProperties() {
|
||||
this.serverProperties.setForwardHeadersStrategy(ForwardHeadersStrategy.NONE);
|
||||
this.serverProperties.setMaxHttpHeaderSize(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue