From 9936b4da60ce8958cd5cc82c31378121b16542b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=8C=AF=E5=B9=BF?= Date: Fri, 30 Oct 2020 22:15:24 +0800 Subject: [PATCH] Improve default block fallback logic in Dubbo 2.6.x adapter to avoid serialization problem (#1794) - convert BlockException to a simple RuntimeException (with necessary message) --- .../adapter/dubbo/fallback/DefaultDubboFallback.java | 6 ++++-- .../adapter/dubbo/fallback/DubboFallbackRegistryTest.java | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sentinel-adapter/sentinel-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/fallback/DefaultDubboFallback.java b/sentinel-adapter/sentinel-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/fallback/DefaultDubboFallback.java index de3058c5..b893a558 100644 --- a/sentinel-adapter/sentinel-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/fallback/DefaultDubboFallback.java +++ b/sentinel-adapter/sentinel-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/fallback/DefaultDubboFallback.java @@ -29,7 +29,9 @@ public class DefaultDubboFallback implements DubboFallback { @Override public Result handle(Invoker invoker, Invocation invocation, BlockException ex) { - // Just wrap the exception. - return new RpcResult(new SentinelRpcException(ex)); + // Just wrap the exception. edit by wzg923 2020/9/23 + RpcResult result = new RpcResult(); + result.setException(new SentinelRpcException(ex.toRuntimeException())); + return result; } } diff --git a/sentinel-adapter/sentinel-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/dubbo/fallback/DubboFallbackRegistryTest.java b/sentinel-adapter/sentinel-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/dubbo/fallback/DubboFallbackRegistryTest.java index 441b48aa..edcd2a01 100644 --- a/sentinel-adapter/sentinel-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/dubbo/fallback/DubboFallbackRegistryTest.java +++ b/sentinel-adapter/sentinel-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/dubbo/fallback/DubboFallbackRegistryTest.java @@ -23,7 +23,6 @@ import com.alibaba.dubbo.rpc.Invocation; import com.alibaba.dubbo.rpc.Invoker; import com.alibaba.dubbo.rpc.Result; import com.alibaba.dubbo.rpc.RpcResult; - import org.junit.Assert; import org.junit.Test;