Skip to content

Support intercepting non-reactive InvocableHandlerMethod in RequestMappingHandlerAdapter chain #35438

@krezovic

Description

@krezovic

Spring Framework 6.2 added support for offloading non-reactive method to an executor, which Spring Boot configures when virtual threads are enabled.

I was hoping I could simply change my app that's currently running with Spring WebMVC and Tomcat to Spring WebFlux and Netty when enabling virtual threads.

There are several RestControllers that perform blocking database and rest calls, and they work as expected when I change the underlying web application type and server.

I am, however, missing a way to inject non-reactive ContextHolder variants that use thread locals, such as RequestContextHolder, LocaleContextHolder and SecurityContextHolder.

I am aware I could wrap each method with reactive variants, but I'd appreaciate if there was a way I could intercept the method call and map the mentioned ContextHolders from their Reactive counterparts without having to modify any code.

Anything that wraps method::invoke call to target method into something that can access ServerWebExchange would be welcome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions