We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
请问下,在spring boot 场景下,filter 中进入时set ,但是业务中异步线程还未执行完,filter 请求已经finally remove了,这时获取到的值为null, 这种情况如何保证正确性
The text was updated successfully, but these errors were encountered:
对于TTL本身逻辑/功能, 主线程的修改(filter请求的remove)不会影响 给子任务传递了的值。
TTL
filter
remove
一般是因为ThreadLocal的值使用了共享的集合(如Map),所以修改子任务可见。可以看看: @freshgeek
ThreadLocal
这个TTL使用方式/问题的解决方法,可以看看:
更多可以看看:
Sorry, something went wrong.
TransmittableThreadLocal数据丢失问题 https://juejin.cn/post/7311500203432575026
executor.setTaskDecorator(runnable -> TtlRunnable.get(runnable, true)); // 推荐改成 executor.setTaskDecorator(TtlRunnable::get); // 以避免不能在线程池中运行(可能)多次重复运行的任务
oldratlee
No branches or pull requests
请问下,在spring boot 场景下,filter 中进入时set ,但是业务中异步线程还未执行完,filter 请求已经finally remove了,这时获取到的值为null, 这种情况如何保证正确性
The text was updated successfully, but these errors were encountered: