Document that Filter beans are eagerly initialized

Closes gh-17814
This commit is contained in:
Phillip Webb
2019-08-31 08:41:34 -07:00
parent 7e60f4b32a
commit e07889b092

View File

@@ -2663,6 +2663,9 @@ It is usually safe to leave Filter beans unordered.
If a specific order is required, you should avoid configuring a Filter that reads the request body at `Ordered.HIGHEST_PRECEDENCE`, since it might go against the character encoding configuration of your application.
If a Servlet filter wraps the request, it should be configured with an order that is less than or equal to `OrderedFilter.REQUEST_WRAPPER_FILTER_MAX_ORDER`.
WARNING: Take care when registering `Filter` beans since they are initialized very early in the application lifectyle.
If you need to register a `Filter` that interacts with other beans, consider using a {spring-boot-module-api}/web/servlet/DelegatingFilterProxyRegistrationBean.html[`DelegatingFilterProxyRegistrationBean`] instead.
[[boot-features-embedded-container-context-initializer]]