You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2019/12/20 02:46:41 UTC
[dubbo] branch master updated: check whether the GenericFilter args
and types length are the same (#4990)
This is an automated email from the ASF dual-hosted git repository.
liujun 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 ad2d30b check whether the GenericFilter args and types length are the same (#4990)
ad2d30b is described below
commit ad2d30ba90eaea6074fbe4c2497789e0545e915c
Author: 孙传磊 <13...@qq.com>
AuthorDate: Fri Dec 20 10:46:30 2019 +0800
check whether the GenericFilter args and types length are the same (#4990)
---
.../java/org/apache/dubbo/rpc/filter/GenericFilter.java | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericFilter.java
index 44f6b77..51b014c 100644
--- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericFilter.java
+++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericFilter.java
@@ -70,8 +70,12 @@ public class GenericFilter implements Filter, Filter.Listener {
if (args == null) {
args = new Object[params.length];
}
- String generic = (String) inv.getAttachment(GENERIC_KEY);
+ if (args.length != types.length) {
+ throw new RpcException("args.length != types.length");
+ }
+ String generic = (String) inv.getAttachment(GENERIC_KEY);
+
if (StringUtils.isBlank(generic)) {
generic = (String) RpcContext.getContext().getAttachment(GENERIC_KEY);
}
@@ -120,7 +124,7 @@ public class GenericFilter implements Filter, Filter.Listener {
try (UnsafeByteArrayInputStream is =
new UnsafeByteArrayInputStream(((String) args[0]).getBytes())) {
args[0] = ExtensionLoader.getExtensionLoader(Serialization.class)
- .getExtension("" + GENERIC_SERIALIZATION_PROTOBUF)
+ .getExtension(GENERIC_SERIALIZATION_PROTOBUF)
.deserialize(null, is).readObject(method.getParameterTypes()[0]);
} catch (Exception e) {
throw new RpcException("Deserialize argument failed.", e);
@@ -129,20 +133,19 @@ public class GenericFilter implements Filter, Filter.Listener {
throw new RpcException(
"Generic serialization [" +
GENERIC_SERIALIZATION_PROTOBUF +
- "] only support one" + String.class.getName() +
+ "] only support one " + String.class.getName() +
" argument and your message size is " +
args.length + " and type is" +
args[0].getClass().getName());
}
}
+
RpcInvocation rpcInvocation = new RpcInvocation(method, invoker.getInterface().getName(), args, inv.getAttachments(), inv.getAttributes());
rpcInvocation.setInvoker(inv.getInvoker());
rpcInvocation.setTargetServiceUniqueName(inv.getTargetServiceUniqueName());
return invoker.invoke(rpcInvocation);
- } catch (NoSuchMethodException e) {
- throw new RpcException(e.getMessage(), e);
- } catch (ClassNotFoundException e) {
+ } catch (NoSuchMethodException | ClassNotFoundException e) {
throw new RpcException(e.getMessage(), e);
}
}