From 8d98d656b7f8a402708d5b93398e0778ea6a8869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E7=A6=B9=E5=85=89?= Date: Fri, 21 Feb 2020 16:09:01 +0800 Subject: [PATCH 1/2] sentinel-apache-dubbo-adapter not compatible dubbo 2.7.5 --- .../sentinel-apache-dubbo-adapter/pom.xml | 2 +- .../adapter/dubbo/BaseSentinelDubboFilter.java | 16 ++++++++++------ .../dubbo/SentinelDubboConsumerFilterTest.java | 4 ++-- .../dubbo/SentinelDubboProviderFilterTest.java | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/sentinel-adapter/sentinel-apache-dubbo-adapter/pom.xml b/sentinel-adapter/sentinel-apache-dubbo-adapter/pom.xml index 5ccf18467c..44f799db5e 100644 --- a/sentinel-adapter/sentinel-apache-dubbo-adapter/pom.xml +++ b/sentinel-adapter/sentinel-apache-dubbo-adapter/pom.xml @@ -15,7 +15,7 @@ 1.8 1.8 - 2.7.3 + 2.7.5 diff --git a/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/BaseSentinelDubboFilter.java b/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/BaseSentinelDubboFilter.java index 9ea01e59da..bc2101ffb2 100644 --- a/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/BaseSentinelDubboFilter.java +++ b/sentinel-adapter/sentinel-apache-dubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/BaseSentinelDubboFilter.java @@ -22,11 +22,7 @@ import com.alibaba.csp.sentinel.context.ContextUtil; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.constants.CommonConstants; -import org.apache.dubbo.rpc.Invocation; -import org.apache.dubbo.rpc.Invoker; -import org.apache.dubbo.rpc.ListenableFilter; -import org.apache.dubbo.rpc.Result; -import org.apache.dubbo.rpc.RpcContext; +import org.apache.dubbo.rpc.*; /** * Base Class of the {@link SentinelDubboProviderFilter} and {@link SentinelDubboConsumerFilter}. @@ -41,8 +37,16 @@ public BaseSentinelDubboFilter() { static class SentinelDubboListener implements Listener { - @Override public void onResponse(Result appResponse, Invoker invoker, Invocation invocation) { + onSuccess(appResponse, invoker); + } + + //for compatible dubbo 2.7.5 rename onResponse to onMessage + public void onMessage(Result appResponse, Invoker invoker, Invocation invocation) { + onSuccess(appResponse, invoker); + } + + private void onSuccess(Result appResponse, Invoker invoker) { if (DubboConfig.getDubboBizExceptionTraceEnabled()) { traceAndExit(appResponse.getException(), invoker.getUrl()); } else { diff --git a/sentinel-adapter/sentinel-apache-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboConsumerFilterTest.java b/sentinel-adapter/sentinel-apache-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboConsumerFilterTest.java index f949231bc3..ea69ab8bdb 100644 --- a/sentinel-adapter/sentinel-apache-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboConsumerFilterTest.java +++ b/sentinel-adapter/sentinel-apache-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboConsumerFilterTest.java @@ -227,7 +227,7 @@ public Result requestGo(boolean exception, Invocation currentInvocation) { } public Result responseBack(Result result) { - filter.listener().onResponse(result, invoker, invocation); + filter.listener().onMessage(result, invoker, invocation); return result; } @@ -265,7 +265,7 @@ public void testInvokeSync() { filter.invoke(invoker, invocation); verify(invoker).invoke(invocation); - filter.listener().onResponse(result, invoker, invocation); + filter.listener().onMessage(result, invoker, invocation); Context context = ContextUtil.getContext(); assertNull(context); } diff --git a/sentinel-adapter/sentinel-apache-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboProviderFilterTest.java b/sentinel-adapter/sentinel-apache-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboProviderFilterTest.java index 1a7000f1d6..ed97800a41 100644 --- a/sentinel-adapter/sentinel-apache-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboProviderFilterTest.java +++ b/sentinel-adapter/sentinel-apache-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/dubbo/SentinelDubboProviderFilterTest.java @@ -89,7 +89,7 @@ public void testInvoke() { filter.invoke(invoker, invocation); verify(invoker).invoke(invocation); - filter.listener().onResponse(result, invoker, invocation); + filter.listener().onMessage(result, invoker, invocation); Context context = ContextUtil.getContext(); assertNull(context); } From 30da30b8541d238c19d20d9593db98bba3f2defd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E7=A6=B9=E5=85=89?= Date: Fri, 21 Feb 2020 16:41:28 +0800 Subject: [PATCH 2/2] sentinel-apache-dubbo-adapter not compatible dubbo 2.7.5 --- .../csp/sentinel/adapter/dubbo/DubboAppContextFilterTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentinel-adapter/sentinel-apache-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/dubbo/DubboAppContextFilterTest.java b/sentinel-adapter/sentinel-apache-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/dubbo/DubboAppContextFilterTest.java index 8c8721e1e8..60a7de2248 100644 --- a/sentinel-adapter/sentinel-apache-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/dubbo/DubboAppContextFilterTest.java +++ b/sentinel-adapter/sentinel-apache-dubbo-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/dubbo/DubboAppContextFilterTest.java @@ -70,6 +70,6 @@ public void testInvokeNullApplicationKey() { verify(invoker).invoke(invocation); String application = RpcContext.getContext().getAttachment(DubboUtils.SENTINEL_DUBBO_APPLICATION_KEY); - assertNull(application); + assertEquals(application, ""); } }