Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
* @author Brian Clozel
* @author Olivier Lamy
* @author Chentao Qu
* @author Artsiom Yudovin
*/
@ConfigurationProperties(prefix = "server", ignoreUnknownFields = true)
public class ServerProperties {
Expand Down Expand Up @@ -369,6 +370,15 @@ public static class Tomcat {
*/
private int acceptCount = 100;

/**
* The maximum number of idle processors that will be retained in the cache and
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you but we're not there yet. Could you please look at other keys in ServerProperties for inspiration? Key description does not start with a or the and can't contain javadoc tags as these are not processed by the annotation processed. We don't document default value either as the value is already set there and made available in the metadata.

Looking at your update, this looks ideal to me:

Maximum number of idle processors that will be retained in the cache and reused with a subsequent request.

Please note that key descriptions are not meant to copy/paste the official documentation of the thing it's configuring.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, thx for advice

* re-used with a subsequent request. The default is 200. A value of -1 means
* unlimited. In the unlimited case, the theoretical maximum number of cached
* Processor objects is {@link #getMaxConnections()} although it will usually be
* closer to {@link #getMaxThreads()}.
*/
private int processorCache = 200;

/**
* Comma-separated list of additional patterns that match jars to ignore for TLD
* scanning. The special '?' and '*' characters can be used in the pattern to
Expand Down Expand Up @@ -524,6 +534,14 @@ public void setAcceptCount(int acceptCount) {
this.acceptCount = acceptCount;
}

public int getProcessorCache() {
return this.processorCache;
}

public void setProcessorCache(int processorCache) {
this.processorCache = processorCache;
}

public List<String> getAdditionalTldSkipPatterns() {
return this.additionalTldSkipPatterns;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public void customize(ConfigurableTomcatWebServerFactory factory) {
.to((maxConnections) -> customizeMaxConnections(factory, maxConnections));
propertyMapper.from(tomcatProperties::getAcceptCount).when(this::isPositive)
.to((acceptCount) -> customizeAcceptCount(factory, acceptCount));
propertyMapper.from(tomcatProperties::getProcessorCache).when(this::isPositive)
.to((processorCache) -> customizeProcessorCache(factory, processorCache));
customizeStaticResources(factory);
customizeErrorReportValve(properties.getError(), factory);
}
Expand Down Expand Up @@ -156,6 +158,13 @@ private void customizeConnectionTimeout(ConfigurableTomcatWebServerFactory facto
});
}

private void customizeProcessorCache(ConfigurableTomcatWebServerFactory factory,
int processorCache) {
factory.addConnectorCustomizers((
connector) -> ((AbstractHttp11Protocol<?>) connector.getProtocolHandler())
.setProcessorCache(processorCache));
}

private void customizeRemoteIpValve(ConfigurableTomcatWebServerFactory factory) {
Tomcat tomcatProperties = this.serverProperties.getTomcat();
String protocolHeader = tomcatProperties.getProtocolHeader();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ public void customAcceptCount() {
.isEqualTo(10));
}

@Test
public void customProcessorCache() {
bind("server.tomcat.processor-cache=100");
assertThat(this.serverProperties.getTomcat().getProcessorCache()).isEqualTo(100);
}

@Test
public void customBackgroundProcessorDelay() {
bind("server.tomcat.background-processor-delay=5");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ content into your application. Rather, pick only the properties that you need.
server.tomcat.max-threads=200 # Maximum amount of worker threads.
server.tomcat.min-spare-threads=10 # Minimum amount of worker threads.
server.tomcat.port-header=X-Forwarded-Port # Name of the HTTP header used to override the original port value.
server.tomcat.processor-cache= # The maximum number of idle processors that will be retained in the cache and re-used with a subsequent request. The default is 200. A value of -1 means unlimited.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still a different description than the field javadoc. As indicated previously, they must be identical.

(When a description is a bit more lengthy than usual, we take the first sentence only but that's not the case here).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, thx for advice

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the super quick update on the suggestions!

server.tomcat.protocol-header= # Header that holds the incoming protocol, usually named "X-Forwarded-Proto".
server.tomcat.protocol-header-https-value=https # Value of the protocol header indicating whether the incoming request uses SSL.
server.tomcat.redirect-context-root=true # Whether requests to the context root should be redirected by appending a / to the path.
Expand Down