Issue Description
1.通过sentinel-dubbo-adapter埋点抛出了SentinelRpcException,Dubbo框架经过
com.alibaba.dubbo.common.utils.StringUtils.toString(SentinelRpcException)处理后抛出了RpcException或RuntimeException,这时在调用方捕获到RpcException或RuntimeException,用BlockException#isBlockException判断是false,Dubbo通过这个工具类处理是为了避免调用方法反序列化失败,但实际上发生了流控,能否考虑通过判断message的方式返回true呢?
2.BlockException类有如下定义和判断:
public static final String BLOCK_EXCEPTION_FLAG = "SentinelBlockException";
public static RuntimeException THROW_OUT_EXCEPTION = new RuntimeException(BLOCK_EXCEPTION_FLAG);
...
if ((cause instanceof BlockException) || (BLOCK_EXCEPTION_FLAG.equals(cause.getMessage()))) {
...
在工程中搜索,这个THROW_OUT_EXCEPTION并没有用到,也就是判断里不会走到后面那个或分支,为什么用这个cause.getMessage()和"SentinelBlockException"判断? 要不要把SentinelRpcException、BlockException、FlowException也加上
Describe what happened (or what feature you want)
测试代码:
// true
FlowException flowException = new FlowException("test");
System.out.println(BlockException.isBlockException(flowException));
// true
SentinelRpcException sentinelRpcException = new SentinelRpcException(flowException);
System.out.println(BlockException.isBlockException(sentinelRpcException));
// false
RuntimeException runtimeException = new RuntimeException(com.alibaba.dubbo.common.utils.StringUtils.toString(sentinelRpcException));
System.out.println(BlockException.isBlockException(runtimeException));
// false
RpcException rpcException = new RpcException(com.alibaba.dubbo.common.utils.StringUtils.toString(sentinelRpcException));
System.out.println(BlockException.isBlockException(rpcException));
Describe what you expected to happen
期望如果Message中有SentinelRpcException、FlowException、DegradeException、BlockException等,BlockException#isBlockException能返回true,这样便于dubbo在捕获异常,区分是Sentinel的流控异常;
但这样通过message判断是否合理,有没有更好的方式。
#374 在dubbo-demo的例子里也有此需求
Issue Description
1.通过sentinel-dubbo-adapter埋点抛出了
SentinelRpcException,Dubbo框架经过com.alibaba.dubbo.common.utils.StringUtils.toString(SentinelRpcException)处理后抛出了RpcException或RuntimeException,这时在调用方捕获到RpcException或RuntimeException,用BlockException#isBlockException判断是false,Dubbo通过这个工具类处理是为了避免调用方法反序列化失败,但实际上发生了流控,能否考虑通过判断message的方式返回true呢?2.
BlockException类有如下定义和判断:在工程中搜索,这个
THROW_OUT_EXCEPTION并没有用到,也就是判断里不会走到后面那个或分支,为什么用这个cause.getMessage()和"SentinelBlockException"判断? 要不要把SentinelRpcException、BlockException、FlowException也加上Describe what happened (or what feature you want)
测试代码:
Describe what you expected to happen
期望如果Message中有SentinelRpcException、FlowException、DegradeException、BlockException等,
BlockException#isBlockException能返回true,这样便于dubbo在捕获异常,区分是Sentinel的流控异常;但这样通过message判断是否合理,有没有更好的方式。
#374 在dubbo-demo的例子里也有此需求