I'm facing issue where, sometimes, async thread is NOT copying Request Scope properties through :
@Override
public <T> Future<T> submit(Callable<T> task) {
return super.submit(
new ContextAwareCallable(task, RequestContextHolder.currentRequestAttributes()));
}
@Override
public T call() throws Exception {
if (context != null) {
RequestContextHolder.setRequestAttributes(context);
}
try {
return task.call();
} finally {
RequestContextHolder.resetRequestAttributes();
}
}
Due to this, getting below exception:
**org.springframework.beans.factory.support.ScopeNotActiveException:**
Error creating bean with name 'scopedTarget.sessionClient'
:
Scope 'request' is not active for the current thread;
consider defining a scoped proxy for this bean if you intend to refer to it from a singleton;
nested exception is java.lang.IllegalStateException:
Cannot ask for request attribute - request is not active anymore!
Please suggest a concrete way to copy request attributes in new thread? OR way to identify that request is executing through Async thread OR main thread?
TIA