java - Spring Security 和异步执行

标签 java spring asynchronous spring-security

我最近发现自己遇到了 Lukasz 描述的同样问题 here 。虽然这个问题的答案被证明很有帮助并最终帮助我解决了我的问题,但我希望有人知道为什么 ThreadPoolTask​​Executor 不能正确处理 MODE_INHERITABLETHREADLOCAL?此问题是否与 ThreadPoolTask​​Executor 无关?

谢谢! 瑞安

最佳答案

好的,根据this post在spring源码论坛中,子线程中的值仅在创建线程时从父线程设置。如果您有一个可供重用的线程池,则除非您更改该值,否则不会再次设置该值。

我引用帖子内容

You seem to want the context of the calling thread (which invokes the executor) to be used instead of the context of the creating thread. This isn't the same as using an inherited thread-local, so that's not the way to go. You would be better to set the context explicitly yourself, or customize the executor implementation to do so.

关于java - Spring Security 和异步执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13462642/

相关文章:

javascript - 如何简化tamejs中的错误处理?

java - 如何为 activeElement 设置变量?

java - 是否有 "embedded DBMS"来支持同一数据库文件上的多个编写器应用程序(进程)?

java - 嵌套异常是 java.lang.NoSuchMethodError : org. hibernate.integrator.internal.IntegratorServiceImpl.<init>

python - 如何在不阻塞主线程的情况下执行 "fire and forget"任务?

c# - 在 Linqpad 中使用 C# 5 异步功能

java - Java 中的嵌入式 NIO http 客户端/服务器

java - 如何正确序列化和反序列化 CSV?

Spring security的Java配置不识别/j_spring_security_check

java - 升级 spring 集成