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/06/28 11:28:05 UTC
[dubbo] branch master updated: generic serialization decode need
use readObject() (#8141)
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 af3c52d generic serialization decode need use readObject() (#8141)
af3c52d is described below
commit af3c52dab4e0daa4af671eb4a1a00cc56e4eeddf
Author: Owen.Cai <89...@qq.com>
AuthorDate: Mon Jun 28 19:27:55 2021 +0800
generic serialization decode need use readObject() (#8141)
* generic serialization decode need use readObject()
* fix import *
---
.../java/org/apache/dubbo/rpc/support/RpcUtils.java | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/RpcUtils.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/RpcUtils.java
index aebb054..c344437 100644
--- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/RpcUtils.java
+++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/RpcUtils.java
@@ -44,6 +44,7 @@ import static org.apache.dubbo.rpc.Constants.ASYNC_KEY;
import static org.apache.dubbo.rpc.Constants.AUTO_ATTACH_INVOCATIONID_KEY;
import static org.apache.dubbo.rpc.Constants.ID_KEY;
import static org.apache.dubbo.rpc.Constants.RETURN_KEY;
+import static org.apache.dubbo.rpc.Constants.GENERIC_KEY;
/**
* RpcUtils
@@ -77,10 +78,20 @@ public class RpcUtils {
&& invocation.getInvoker().getUrl() != null
&& invocation.getInvoker().getInterface() != GenericService.class
&& !invocation.getMethodName().startsWith("$")) {
- String service = invocation.getInvoker().getUrl().getServiceInterface();
- if (StringUtils.isNotEmpty(service)) {
- Method method = getMethodByService(invocation, service);
- return ReflectUtils.getReturnTypes(method);
+ /**
+ * if is generic, must use readObject()
+ * the serialization like hession2, avro when use readObject(class), when the class is Template like class A<T>
+ * it use the A class to create and T is jsonobject, so it muse be error
+ * so it can depend to the data describe or GenericImplFilter to PojoUtils.realize it use Type
+ * of course we can change the serialization to use Type to create, but this work is to large....
+ */
+ String generic = invocation.getInvoker().getUrl().getParameter(GENERIC_KEY);
+ if(!ProtocolUtils.isGeneric(generic)){
+ String service = invocation.getInvoker().getUrl().getServiceInterface();
+ if (StringUtils.isNotEmpty(service)) {
+ Method method = getMethodByService(invocation, service);
+ return ReflectUtils.getReturnTypes(method);
+ }
}
}
} catch (Throwable t) {