Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -381,6 +382,19 @@ public static class Tomcat {
*/
private final Resource resource = new Resource();

/**
* Configuring processor cache.
Copy link
Member

Choose a reason for hiding this comment

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

Can you please polish the property description?

*/
private int processorCache = 200;
Copy link
Member

Choose a reason for hiding this comment

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

We try to order things a bit more naturally. This property could be moved below acceptCount.


public int getProcessorCache() {
Copy link
Member

Choose a reason for hiding this comment

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

The getter/setter pair should be added in the right order (after the one for acceptCount) rather than adding them where they are now.

return this.processorCache;
}

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

public int getMaxThreads() {
return this.maxThreads;
}
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 @@ -280,6 +280,12 @@ public void testCustomizeMinSpareThreads() {
assertThat(this.serverProperties.getTomcat().getMinSpareThreads()).isEqualTo(10);
}

@Test
Copy link
Member

Choose a reason for hiding this comment

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

Ditto. Please add this test after customAcceptCount

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

@Test
public void accessLogBufferingCanBeDisabled() {
bind("server.tomcat.accesslog.enabled=true",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ content into your application. Rather, pick only the properties that you need.
server.tomcat.resource.cache-ttl= # Time-to-live of the static resource cache.
server.tomcat.uri-encoding=UTF-8 # Character encoding to use to decode the URI.
server.tomcat.use-relative-redirects= # Whether HTTP 1.1 and later location headers generated by a call to sendRedirect will use relative or absolute redirects.
server.tomcat.processor-cache= # Custom value for Tomcat's processor cache.
Copy link
Member

Choose a reason for hiding this comment

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

Properties are ordered in natural order. This property must be moved.

Also, the field description must match the description here.

server.undertow.accesslog.dir= # Undertow access log directory.
server.undertow.accesslog.enabled=false # Whether to enable the access log.
server.undertow.accesslog.pattern=common # Format pattern for access logs.
Expand Down