mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Fix Jetty ConnectionLimit configuration
See gh-39052
This commit is contained in:
parent
793801b9cb
commit
7113c10b08
@ -116,6 +116,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Venil Noronha
|
||||
* @author Henri Kerola
|
||||
* @author Moritz Halbritter
|
||||
* @author Onur Kagan Ozcan
|
||||
* @since 2.0.0
|
||||
* @see #setPort(int)
|
||||
* @see #setConfigurations(Collection)
|
||||
@ -183,7 +184,7 @@ public class JettyServletWebServerFactory extends AbstractServletWebServerFactor
|
||||
server.setHandler(addHandlerWrappers(context));
|
||||
this.logger.info("Server initialized with port: " + port);
|
||||
if (this.maxConnections > -1) {
|
||||
server.addBean(new ConnectionLimit(this.maxConnections, server));
|
||||
server.addBean(new ConnectionLimit(this.maxConnections, server.getConnectors()));
|
||||
}
|
||||
if (Ssl.isEnabled(getSsl())) {
|
||||
customizeSsl(server, address);
|
||||
|
@ -72,6 +72,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.InstanceOfAssertFactories.LIST;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.inOrder;
|
||||
@ -85,6 +86,7 @@ import static org.mockito.Mockito.mock;
|
||||
* @author Andy Wilkinson
|
||||
* @author Henri Kerola
|
||||
* @author Moritz Halbritter
|
||||
* @author Onur Kagan Ozcan
|
||||
*/
|
||||
class JettyServletWebServerFactoryTests extends AbstractServletWebServerFactoryTests {
|
||||
|
||||
@ -541,6 +543,17 @@ class JettyServletWebServerFactoryTests extends AbstractServletWebServerFactoryT
|
||||
assertThat(connectionLimit.getMaxConnections()).isOne();
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldApplyingMaxConnectionUseConnector() throws Exception {
|
||||
JettyServletWebServerFactory factory = getFactory();
|
||||
factory.setMaxConnections(1);
|
||||
this.webServer = factory.getWebServer();
|
||||
Server server = ((JettyWebServer) this.webServer).getServer();
|
||||
assertThat(server.getConnectors()).isEmpty();
|
||||
ConnectionLimit connectionLimit = server.getBean(ConnectionLimit.class);
|
||||
assertThat(connectionLimit).extracting("_connectors", LIST).hasSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String startedLogMessage() {
|
||||
return ((JettyWebServer) this.webServer).getStartedLogMessage();
|
||||
|
Loading…
Reference in New Issue
Block a user