Forwarding of RequestContext
not working in async mode
#34706
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: waiting-for-triage
An issue we've not yet triaged or decided on
Describe the bug
Trying to inherit the
RequestContext
to make use of theRequestAttributes
after going into an@Async
thread causesIllegalStateException
with messageCannot ask for request attribute - request is not active anymore!
.To Reproduce
Create the following
Configuration
to setup theRequestContext
inheritance (you can focus on theTaskDecorator
part only if the rest is boilerplate to you):The code below will then fail if the
request
has already completed and the Async task is still running:These calls still seem to work, though:
The validation for this is happening in a class that hasn't changed in a long time, so maybe this is dead code now?
~https://github.com/spring-projects/spring-framework/blob/v6.2.5/spring-web/src/main/java/org/springframework/web/context/request/ServletRequestAttributes.java#L147-L154
Here is an example of a class that starts failing due to this nuance:
~https://github.com/spring-projects/spring-hateoas/blob/2.4.1/src/main/java/org/springframework/hateoas/server/mvc/UriComponentsBuilderFactory.java#L93-L95
The text was updated successfully, but these errors were encountered: