-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Description
Hi, this is a first-timers-only
issue. This means we've worked to make it more legible to folks who either haven't contributed to our codebase before, or even folks who haven't contributed to open source before.
If that's you, we're interested in helping you take the first step and can answer questions and help you out as you do. Note that we're especially interested in contributions from people from groups underrepresented in free and open source software!
If you have contributed before, consider leaving this one for someone new, and looking through our general ideal-for-contribution
issues. Thanks!
Background
Spring Boot provides a number of callback interfaces that can be used to customize the web server. For Tomcat, a TomcatConnectorCustomizer
can be used to customize a Tomcat Connector
and a TomcatContextCustomizer
can be used to customize a Tomcat Context
.
Problem
The customizers can be configured via the addConnectorCustomizers()
and addContextCustomizers()
methods on the ConfigurableTomcatWebServerFactory
. This is bit tedious as can be seen from the example below:
@Bean
public WebServerFactoryCustomizer<TomcatServletWebServerFactory> connectorCustomizer() {
return (tomcat) -> {
tomcat.addConnectorCustomizers(
(connector) -> ((AbstractHttp11Protocol<?>) connector
.getProtocolHandler()).setProcessorCache(250)); // example connector customization
};
}
Instead, if we applied TomcatConnectorCustomizer
and TomcatContextCustomizer
beans automatically, that would simplify the configuration to the following:
@Bean
public TomcatConnectorCustomizer processorCacheCustomizer() {
return (connector) -> (connector) -> ((AbstractHttp11Protocol<?>) connector
.getProtocolHandler()).setProcessorCache(250)); // example connector customization
}
Solution
Beans of both the TomcatContextCustomizer
and TomcatConnectorCustomizer
types should be applied automatically to TomcatServletWebServerFactory
and TomcatReactiveWebServerFactory
. For TomcatServletWebServerFactory
, this can be done here and the configuration for the reactive one can be found here.
The ObjectProvider
interface can be used for injecting a dependency. Here is an example that can be used to inject customizers when there can be 0..n of them.
Tests for the servlet and reactive versions are here and here respectively.
Steps to Fix
- Claim this issue with a comment below and ask any clarifying questions you need
- Set up a repository locally following the Contributing Guidelines
- Try to fix the issue following the steps above
- Commit your changes and start a pull request.