Skip to content

Commit e07889b

Browse files
committed
Document that Filter beans are eagerly initialized
Closes gh-17814
1 parent 7e60f4b commit e07889b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2663,6 +2663,9 @@ It is usually safe to leave Filter beans unordered.
26632663
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.
26642664
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`.
26652665

2666+
WARNING: Take care when registering `Filter` beans since they are initialized very early in the application lifectyle.
2667+
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.
2668+
26662669

26672670

26682671
[[boot-features-embedded-container-context-initializer]]

0 commit comments

Comments
 (0)