You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/02/23 16:44:44 UTC
[dubbo] branch master updated: fix genericservice compatible
problem. (#6124)
This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/master by this push:
new 3bcb195 fix genericservice compatible problem. (#6124)
3bcb195 is described below
commit 3bcb195f3ace9b6eb1e9ad1b170320c6e21a8547
Author: wiki <dr...@outlook.com>
AuthorDate: Wed Feb 24 00:44:25 2021 +0800
fix genericservice compatible problem. (#6124)
---
.../apache/dubbo/generic/GenericServiceTest.java | 24 ++++++++++++++++++++++
.../dubbo/rpc/proxy/AbstractProxyFactory.java | 2 +-
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/dubbo-compatible/src/test/java/org/apache/dubbo/generic/GenericServiceTest.java b/dubbo-compatible/src/test/java/org/apache/dubbo/generic/GenericServiceTest.java
index ec9a08e..7b012d4 100644
--- a/dubbo-compatible/src/test/java/org/apache/dubbo/generic/GenericServiceTest.java
+++ b/dubbo-compatible/src/test/java/org/apache/dubbo/generic/GenericServiceTest.java
@@ -18,6 +18,7 @@
package org.apache.dubbo.generic;
+import com.alibaba.dubbo.config.ReferenceConfig;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.metadata.definition.ServiceDefinitionBuilder;
@@ -89,6 +90,29 @@ public class GenericServiceTest {
}
@Test
+ public void testGenericCompatible() {
+ DemoService server = new DemoServiceImpl();
+ ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
+ Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
+ URL url = URL.valueOf("dubbo://127.0.0.1:5342/" + DemoService.class.getName() + "?version=1.0.0&generic=true$timeout=3000");
+ Exporter<DemoService> exporter = protocol.export(proxyFactory.getInvoker(server, DemoService.class, url));
+
+ // simulate normal invoke
+ ReferenceConfig<com.alibaba.dubbo.rpc.service.GenericService> oldReferenceConfig = new ReferenceConfig<>();
+ oldReferenceConfig.setGeneric(true);
+ oldReferenceConfig.setInterface(DemoService.class.getName());
+ oldReferenceConfig.checkAndUpdateSubConfigs();
+ Invoker invoker = protocol.refer(oldReferenceConfig.getInterfaceClass(), url);
+ com.alibaba.dubbo.rpc.service.GenericService client = (com.alibaba.dubbo.rpc.service.GenericService) proxyFactory.getProxy(invoker, true);
+
+ Object result = client.$invoke("sayHello", new String[]{"java.lang.String"}, new Object[]{"haha"});
+ Assertions.assertEquals("hello haha", result);
+
+ invoker.destroy();
+ exporter.unexport();
+ }
+
+ @Test
public void testGenericComplexCompute4FullServiceMetadata() {
DemoService server = new DemoServiceImpl();
ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/proxy/AbstractProxyFactory.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/proxy/AbstractProxyFactory.java
index 837750f..8698fe6 100644
--- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/proxy/AbstractProxyFactory.java
+++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/proxy/AbstractProxyFactory.java
@@ -60,7 +60,7 @@ public abstract class AbstractProxyFactory implements ProxyFactory {
}
if (generic) {
- if (!GenericService.class.isAssignableFrom(invoker.getInterface())) {
+ if (GenericService.class.equals(invoker.getInterface()) || !GenericService.class.isAssignableFrom(invoker.getInterface())) {
interfaces.add(com.alibaba.dubbo.rpc.service.GenericService.class);
}