You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Additional connectors can be created to add additional ports to the TomcatServletWebServerFactory by creating a WebServerFactorCustomizer bean and calling the addAdditionalTomcatConnectors() method, but connectors added this way do not have customization applied from application.properties as one might expect. This is the documented way of adding additional connectors as of 3.1.x doc.
This customization can be manually applied by calling getTomcatConnectorCustomizers(), then calling customize(connector) with each value from the collection returned. This seems to be a workaround instead of creating multiple TomcatWebServers. This could be problematic if there are multiple WebServerFactoryCustomizer beans within a project that call addContextCustomizer() resulting in inconsistent customization being applied to connectors added in different beans.
It should be clearer that connectors created in this way will not have this customization applied.
Thanks for the suggestion but I don't think it makes sense to apply the same customization to every connector automatically. It would be a breaking change and it would also make it harder to have multiple connectors with different configuration. We can update the javadoc of addAdditionalTomcatConnectors() to make it clear that the factory will not apply its connection customizers to the additional connectors.
wilkinsona
changed the title
Apply tomcat application.properties to connectors created for different ports
Document that TomcatConnectorCustomizers are not applied to additional connectors
Nov 2, 2023
Additional connectors can be created to add additional ports to the
TomcatServletWebServerFactory
by creating aWebServerFactorCustomizer
bean and calling theaddAdditionalTomcatConnectors()
method, but connectors added this way do not have customization applied from application.properties as one might expect. This is the documented way of adding additional connectors as of 3.1.x doc.This customization can be manually applied by calling
getTomcatConnectorCustomizers()
, then callingcustomize(connector)
with each value from the collection returned. This seems to be a workaround instead of creating multipleTomcatWebServer
s. This could be problematic if there are multipleWebServerFactoryCustomizer
beans within a project that calladdContextCustomizer()
resulting in inconsistent customization being applied to connectors added in different beans.It should be clearer that connectors created in this way will not have this customization applied.
Related: #17144
The text was updated successfully, but these errors were encountered: