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

Pickup coroutineContext saved by CoWebFilter in coRouter #31793

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

Pickup coroutineContext saved by CoWebFilter in coRouter #31793

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

ilya40umov commented Dec 8, 2023

This was problem initially brought up here: micrometer-metrics/tracing#174 (comment) by @meberhard.

Problem: Currently the only place in Spring Framework that is picking up CoWebFilter.COROUTINE_CONTEXT_ATTRIBUTE is this: https://github.com/spring-projects/spring-framework/blob/main/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java#L296
but this code does not get executed for coRouter handlers. This means that the handlers installed by coRouter won't inherit the coroutineContext from CoWebFilter(s).

Known workarounds: you can add the look up into each instance of coRouter DSL manually:

coRouter {
    context { it.exchange().attributes[CoWebFilter.COROUTINE_CONTEXT_ATTRIBUTE] as CoroutineContext }
    GET("/demo", demoHandler::demoCall)
}

To show case it, I have the following example:

@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