Skip to content

Support for multiple CoWebFilters that change CoroutineContext #31792

Closed
@ilya40umov

Description

@ilya40umov

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:

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

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)theme: kotlinAn issue related to Kotlin supporttype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions