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
com.alibaba.csp.sentinel.Entry
try-with-resources
在使用Sentinel(版本:1.8.2)时,根据其支持try-with-resources的特性,如图: 文档也特别介绍,如图: 本人在做测试时,代码如下: 其中第49行使用了try-with-resources语法,在第59行,使用Tracer.trace(e)跟踪错误信息,测试发现,错误数总为0,后经过调试发现,try-with-resources的close()方法在Tracer.trace(e)方法调用之前已经调用,如图: 也就是com.alibaba.csp.sentinel.Entry提前exit()了,这就导致 ContextUtil.getContext()获取的Context总是为空,如图: 因此也无法记录到错误,如图: 后来看了一下官方web(com.alibaba.csp.sentinel.adapter.spring.webmvc.AbstractSentinelInterceptor#preHandle)和非web(com.alibaba.csp.sentinel.annotation.aspectj.SentinelResourceAspect#invokeResourceWithSentinel)的两个处理类,也都没有用try-with-resources特性(你们这群老六😅),如图: 最后只能采用普通的try-catch-finally,错误数统计才正常,请后续修复一下代码!
Sentinel
1.8.2
49
59
Tracer.trace(e)
0
close()
exit()
ContextUtil.getContext()
Context
web
com.alibaba.csp.sentinel.adapter.spring.webmvc.AbstractSentinelInterceptor#preHandle
com.alibaba.csp.sentinel.annotation.aspectj.SentinelResourceAspect#invokeResourceWithSentinel
try-catch-finally
The text was updated successfully, but these errors were encountered:
No branches or pull requests
在使用
Sentinel
(版本:1.8.2
)时,根据其支持try-with-resources
的特性,如图:文档也特别介绍,如图:
本人在做测试时,代码如下:
其中第
49
行使用了try-with-resources
语法,在第59
行,使用Tracer.trace(e)
跟踪错误信息,测试发现,错误数总为0
,后经过调试发现,try-with-resources
的close()
方法在Tracer.trace(e)
方法调用之前已经调用,如图:也就是
com.alibaba.csp.sentinel.Entry
提前exit()
了,这就导致ContextUtil.getContext()
获取的Context
总是为空,如图:因此也无法记录到错误,如图:
后来看了一下官方
web
(com.alibaba.csp.sentinel.adapter.spring.webmvc.AbstractSentinelInterceptor#preHandle
)和非web
(com.alibaba.csp.sentinel.annotation.aspectj.SentinelResourceAspect#invokeResourceWithSentinel
)的两个处理类,也都没有用try-with-resources
特性(你们这群老六😅),如图:最后只能采用普通的
try-catch-finally
,错误数统计才正常,请后续修复一下代码!The text was updated successfully, but these errors were encountered: