alibaba / transmittable-thread-local

📌 a missing Java std lib(simple & 0-dependency) for framework/middleware, provide an enhanced InheritableThreadLocal that transmits values between threads even using thread pooling components.
https://github.com/alibaba/transmittable-thread-local
Apache License 2.0
7.67k stars 1.69k forks source link

Tocmat8.0.26Version,transmittable2.13.2Version,SpringAsyncRequest时会丢失数据 #409

Closed simonHome closed 2 years ago

simonHome commented 2 years ago

Tocmat=8.0.26V

transmittable=2.13.2V

Spring Async Request时,在Filter中设置ThreadLocal数据,但在Deferredresult.SetResult()后,在filter中HttpServletResponse重写OutStream方法时已经无法从ThreadLocal中获取数据,但在Tocmat=8.044版本中没有发现这个问题.

public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) {
 set ThreadLocal
 HttpServletResponse resWrapper = new HttpServletResponseWrapper(servletResponse) {
            @Override
            public ServletOutputStream getOutputStream() throws IOException {
                get ThreadLocal (8.0.26版本tomcat会丢失,8.0.44版本不会丢失)
            }
}
simonHome commented 2 years ago

又再次验证了一下,只要Tocmat>8.0.26V 版本就可以

oldratlee commented 2 years ago

关于 Tomcat 可以看一下 相关的 issue:

作为TTL的使用(在Tomcat下),这些差异具体要结合Tomcat的实现与TTL的使用方式排查一下使用了。 @simonHome Tomcat我也不熟悉。


这个 issue 先 close 了。