Support for multiple CoWebFilters that change CoroutineContext #31792
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
theme: kotlin
An issue related to Kotlin support
type: bug
A general bug
Milestone
This has been brought up here: #27522 (comment) and here micrometer-metrics/tracing#174 (comment).
Problem: if multiple CoWebFilters are called in a chain, the coroutine context from the last one will end up saved in
CoWebFilter.COROUTINE_CONTEXT_ATTRIBUTE
. Additionally, each subsequent filter won't be able to take advantage of context modifications from the previous filter in the chain.E.g. if I have the following two filters in my project:
only one of them will be able to provide coroutine context for the actual controller method.
Proposed solution: check if attribute is already present in the context and re-use it within the filter. Here is a fast-and-dirty implementation: ImprovedCoWebFilter
The text was updated successfully, but these errors were encountered: