mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Merge pull request #39052 from okohub
* pr/39052: Polish "Fix Jetty ConnectionLimit configuration" Fix Jetty ConnectionLimit configuration Closes gh-39052
This commit is contained in:
commit
47564ccea1
@ -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);
|
||||
|
@ -39,6 +39,7 @@ import org.apache.hc.client5.http.impl.classic.HttpClients;
|
||||
import org.apache.hc.core5.http.Header;
|
||||
import org.apache.hc.core5.http.HttpResponse;
|
||||
import org.apache.jasper.servlet.JspServlet;
|
||||
import org.assertj.core.api.InstanceOfAssertFactories;
|
||||
import org.awaitility.Awaitility;
|
||||
import org.eclipse.jetty.ee10.servlet.ErrorPageErrorHandler;
|
||||
import org.eclipse.jetty.ee10.servlet.ServletHolder;
|
||||
@ -46,6 +47,7 @@ import org.eclipse.jetty.ee10.webapp.AbstractConfiguration;
|
||||
import org.eclipse.jetty.ee10.webapp.ClassMatcher;
|
||||
import org.eclipse.jetty.ee10.webapp.Configuration;
|
||||
import org.eclipse.jetty.ee10.webapp.WebAppContext;
|
||||
import org.eclipse.jetty.server.AbstractConnector;
|
||||
import org.eclipse.jetty.server.ConnectionLimit;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
@ -85,6 +87,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 +544,19 @@ 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")
|
||||
.asInstanceOf(InstanceOfAssertFactories.list(AbstractConnector.class))
|
||||
.hasSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String startedLogMessage() {
|
||||
return ((JettyWebServer) this.webServer).getStartedLogMessage();
|
||||
|
Loading…
Reference in New Issue
Block a user