Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for multiple CoWebFilters that change CoroutineContext #31792

Closed
ilya40umov opened this issue Dec 8, 2023 · 0 comments
Closed

Support for multiple CoWebFilters that change CoroutineContext #31792

ilya40umov opened this issue Dec 8, 2023 · 0 comments
Assignees
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

Comments

@ilya40umov
Copy link
Contributor

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

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 8, 2023
@sdeleuze sdeleuze self-assigned this Dec 11, 2023
@sdeleuze sdeleuze added theme: kotlin An issue related to Kotlin support in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Dec 11, 2023
@sdeleuze sdeleuze added this to the 6.1.2 milestone Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) theme: kotlin An issue related to Kotlin support type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants