From e07889b0921e0a8ee767093c77f217458b27127a Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Sat, 31 Aug 2019 08:41:34 -0700 Subject: [PATCH] Document that Filter beans are eagerly initialized Closes gh-17814 --- .../src/main/asciidoc/spring-boot-features.adoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 94665b2763..e37b99a008 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -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]]