Skip to content

Commit 1c6f2af

Browse files
committed
Clarify how to configure a Filter's order
Closes gh-18266
1 parent 69a95ce commit 1c6f2af

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2676,7 +2676,10 @@ Here are a few examples of Filters and their respective order (lower order value
26762676

26772677
It is usually safe to leave Filter beans unordered.
26782678

2679-
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.
2679+
If a specific order is required, you should annotate the `Filter` with `@Order` or make it implement `Ordered`.
2680+
You cannot configure the order of a `Filter` by annotating its bean method with `@Order`.
2681+
If you cannot change the `Filter` class to add `@Order` or implement `Ordered`, you must define a `FilterRegistrationBean` for the `Filter` and set the registration bean's order using the `setOrder(int)` method.
2682+
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.
26802683
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`.
26812684

26822685
WARNING: Take care when registering `Filter` beans since they are initialized very early in the application lifectyle.

0 commit comments

Comments
 (0)