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

Inherit parent context in coRouter DSL #31831

Closed
sdeleuze opened this issue Dec 13, 2023 · 0 comments
Closed

Inherit parent context in coRouter DSL #31831

sdeleuze opened this issue Dec 13, 2023 · 0 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) theme: kotlin An issue related to Kotlin support type: enhancement A general enhancement
Milestone

Comments

@sdeleuze
Copy link
Contributor

sdeleuze commented Dec 13, 2023

As reported in this Stackoverflow question, the CoroutineContext defined in the parent router is lost in nested routers, which is a surprising behavior. For example with this router, a request on / will have the context set as expected, but not a request on /nested/.

coRouter {
    context { CoroutineName("Custom context") }
    GET("/") {
        ok().bodyValueAndAwait(currentCoroutineContext().toString())
    }
    "/nested".nest {
        GET("/") {
            ok().bodyValueAndAwait(currentCoroutineContext().toString())
        }
    }
}

This issue is about inheriting the CoroutineContext in such use case to provide a more predictable behavior, while still allowing an override in nested routers.

@sdeleuze sdeleuze added in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement theme: kotlin An issue related to Kotlin support labels Dec 13, 2023
@sdeleuze sdeleuze added this to the 6.1.2 milestone Dec 13, 2023
@sdeleuze sdeleuze self-assigned this Dec 13, 2023
@sdeleuze sdeleuze changed the title Inherit parent CoroutineContext in coRouter DSL Inherit parent context in coRouter DSL Dec 13, 2023
sdeleuze added a commit to sdeleuze/spring-framework that referenced this issue Dec 13, 2023
This commit also allow context override, as it
useful for the nested router use case.

Closes spring-projectsgh-31831
sdeleuze added a commit to sdeleuze/spring-framework that referenced this issue Dec 13, 2023
This commit also allow context override, as it
is useful for the nested router use case.

Closes spring-projectsgh-31831
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: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant