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
commit c18e6c367237584cc01c630141262cad9aae9595 Author: beiwei.ly <[email protected]> AuthorDate: Tue Oct 29 15:45:33 2019 +0800 to process a scenario when service type is not available and service invocation is not generic either --- .../src/main/java/org/apache/dubbo/rpc/Invocation.java | 12 ++++++++++++ .../main/java/org/apache/dubbo/rpc/RpcInvocation.java | 18 ++++++++++++++++++ .../org/apache/dubbo/rpc/filter/GenericImplFilter.java | 2 ++ .../java/org/apache/dubbo/rpc/support/RpcUtils.java | 2 +- 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/Invocation.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/Invocation.java index 96520d3..d5a24b0 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/Invocation.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/Invocation.java @@ -17,6 +17,7 @@ package org.apache.dubbo.rpc; import java.util.Map; +import java.util.stream.Stream; /** * Invocation. (API, Prototype, NonThreadSafe) @@ -46,6 +47,17 @@ public interface Invocation { Class<?>[] getParameterTypes(); /** + * get parameter's signature, string representation of parameter types. + * + * @return parameter's signature + */ + default String[] getParameterSignatures() { + return Stream.of(getParameterTypes()) + .map(Class::getName) + .toArray(String[]::new); + } + + /** * get arguments. * * @return arguments. diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcInvocation.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcInvocation.java index fc63bae..b29ee56 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcInvocation.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcInvocation.java @@ -23,6 +23,7 @@ import java.lang.reflect.Method; import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import java.util.stream.Stream; import static org.apache.dubbo.common.constants.CommonConstants.APPLICATION_KEY; import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY; @@ -47,6 +48,8 @@ public class RpcInvocation implements Invocation, Serializable { private Class<?>[] parameterTypes; + private String[] parameterSignatures; + private Object[] arguments; private Map<String, Object> attachments; @@ -118,6 +121,10 @@ public class RpcInvocation implements Invocation, Serializable { public RpcInvocation(String methodName, Class<?>[] parameterTypes, Object[] arguments, Map<String, Object> attachments, Invoker<?> invoker) { this.methodName = methodName; this.parameterTypes = parameterTypes == null ? new Class<?>[0] : parameterTypes; + this.parameterSignatures = parameterTypes == null ? null : + Stream.of(getParameterTypes()) + .map(Class::getName) + .toArray(String[]::new); this.arguments = arguments == null ? new Object[0] : arguments; this.attachments = attachments == null ? new HashMap<String, Object>() : attachments; this.invoker = invoker; @@ -168,10 +175,21 @@ public class RpcInvocation implements Invocation, Serializable { return parameterTypes; } + @Override + public String[] getParameterSignatures() { + return parameterSignatures; + } + public void setParameterTypes(Class<?>[] parameterTypes) { this.parameterTypes = parameterTypes == null ? new Class<?>[0] : parameterTypes; } + // parameter signatures can be set independently, it is useful when the service type is not found on caller side and + // the invocation is not generic invocation either. + public void setParameterSignatures(String[] parameterSignatures) { + this.parameterSignatures = parameterSignatures; + } + @Override public Object[] getArguments() { return arguments; diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericImplFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericImplFilter.java index 0fd0d82..2277f27 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericImplFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericImplFilter.java @@ -32,6 +32,7 @@ import org.apache.dubbo.rpc.Result; import org.apache.dubbo.rpc.RpcException; import org.apache.dubbo.rpc.RpcInvocation; import org.apache.dubbo.rpc.service.GenericException; +import org.apache.dubbo.rpc.service.GenericService; import org.apache.dubbo.rpc.support.ProtocolUtils; import org.apache.dubbo.rpc.support.RpcUtils; @@ -130,6 +131,7 @@ public class GenericImplFilter extends ListenableFilter { String methodName = invocation.getMethodName(); Class<?>[] parameterTypes = invocation.getParameterTypes(); if (ProtocolUtils.isGeneric(generic) + && GenericService.class != invoker.getInterface() && (!$INVOKE.equals(invocation.getMethodName()) && !$INVOKE_ASYNC.equals(invocation.getMethodName())) && invocation instanceof RpcInvocation) { if (!appResponse.hasException()) { 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 60ed621..94faa57 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 @@ -62,7 +62,7 @@ public class RpcUtils { } } } catch (Throwable t) { - logger.warn(t.getMessage(), t); + // ignore } return null; }
