32243 added a built-in ThreadLocalAccessor
adapter for RequestContextHolder
. However, the FrameworkServlet
which manages the thread local, also calls RequestAttributes#requestCompleted
on the way out, so in case of an asynchronous request, the propagated RequestAttributes
instance ends up having requestActive=false
which results in IllegalStateException
if you try access any attributes.
We need to consider how to address this. The simplest option would be to create a separate ServletRequestAttributes
instance for context propagation purposes.
Comment From: snicoll
I've moved this to a task as the original proposal is not released yet and therefore this isn't user facing if it is fixed in the same milestone.
Comment From: dsyer
There's a link to a sample SSE renderer project in https://github.com/spring-projects/spring-framework/issues/32112. It breaks if you use the ThreadLocalAccessor
from 6.2 snapshots, but not by throwing exceptions - you just get a null request context where you needed it to be not-null. So I'm not sure the IllegalStateException
mentioned above is the only problem with async requests.
Comment From: izeye
I've moved this to a task as the original proposal is not released yet and therefore this isn't user facing if it is fixed in the same milestone.
This seems to have been fixed in 6.2.0-M2 while https://github.com/spring-projects/spring-framework/pull/32243 seems to have been released in 6.2.0-M1, so it seems better to be labeled as a bug now.