Ordering of WebClient.filter(s) [SPR-15657]
See original GitHub issueJoe Grandja opened SPR-15657 and commented
Given this filter configuration for WebClient
:
this.webClient
.filter(filter1())
.filter(filter2())
.filter(filter3())
.filter(filter4())
The expectation is that the filters would be applied in the following order: filter1, filter2, filter3, filter4
. However, that is not the case, as they are applied in reverse order.
It seems a bit confusing compared to the way a Reactive stream is defined and executed in a top-down approach (the way the code reads).
Does it make sense to have the filters applied in the order they are defined - top-down approach?
Affects: 5.0 RC1
Issue Links:
- #20250 Simplify applying a strategy to requests from WebTestClient and WebTestClient
0 votes, 5 watchers
Issue Analytics
- State:
- Created 6 years ago
- Comments:24
Top Results From Across the Web
Spring WebClient Filters - Baeldung
A filter can intercept, examine, and modify a client request (or response). Filters are very suitable for adding functionality to every single ...
Read more >WebClient filters doOnNext called in reverse order
The filter1 is invoked after filter2 but doOnNext is invoked in the reverse order. I read this discussion https://github.com/spring-projects/ ...
Read more >WebClient.Builder (Spring Framework 5.0.9.RELEASE API)
Manipulate the filters with the given consumer. The list provided to the consumer is "live", so that the consumer can be used to...
Read more >Spring 5 WebClient and WebTestClient Tutorial with Examples
WebClient is a non-blocking, reactive HTTP client with a fluent ... you a bunch of customization options including filters, default headers, ...
Read more >Customize Spring WebClient with WebClientCustomizer
The automatic registration of our WebClient customizations is done ... @Order(0) ... cookies, exchange strategies, filters, and much more.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Joe Grandja commented
Arjen, I forgot about the option of
andThen
for composition. This ordering is clear to me using that approach and may be what I end up using. Thanks for the tip.Arjen Poutsma commented
NPE fixed in https://github.com/spring-projects/spring-framework/commit/4f39edc9059bf3896e996224003599261412c004