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/03 03:16:32 UTC
[dubbo] branch master updated: [Performance tuning] improve
InvokerInvocationHandler#invoke (#5403)
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 cd582c5 [Performance tuning] improve InvokerInvocationHandler#invoke (#5403)
cd582c5 is described below
commit cd582c5c036a92296b5fbf844f44c1c67ae26e76
Author: hengyunabc <he...@gmail.com>
AuthorDate: Tue Dec 3 11:15:53 2019 +0800
[Performance tuning] improve InvokerInvocationHandler#invoke (#5403)
---
.../dubbo/rpc/proxy/InvokerInvocationHandler.java | 26 ++++++++++------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/proxy/InvokerInvocationHandler.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/proxy/InvokerInvocationHandler.java
index 725e573..c10369c 100644
--- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/proxy/InvokerInvocationHandler.java
+++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/proxy/InvokerInvocationHandler.java
@@ -37,25 +37,23 @@ public class InvokerInvocationHandler implements InvocationHandler {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- String methodName = method.getName();
- Class<?>[] parameterTypes = method.getParameterTypes();
if (method.getDeclaringClass() == Object.class) {
return method.invoke(invoker, args);
}
- if ("toString".equals(methodName) && parameterTypes.length == 0) {
- return invoker.toString();
- }
- if ("hashCode".equals(methodName) && parameterTypes.length == 0) {
- return invoker.hashCode();
- }
- if ("equals".equals(methodName) && parameterTypes.length == 1) {
+ String methodName = method.getName();
+ Class<?>[] parameterTypes = method.getParameterTypes();
+ if (parameterTypes.length == 0) {
+ if ("toString".equals(methodName)) {
+ return invoker.toString();
+ } else if ("$destroy".equals(methodName)) {
+ invoker.destroy();
+ return null;
+ } else if ("hashCode".equals(methodName)) {
+ return invoker.hashCode();
+ }
+ } else if (parameterTypes.length == 1 && "equals".equals(methodName)) {
return invoker.equals(args[0]);
}
- if ("$destroy".equals(methodName) && parameterTypes.length == 0) {
- invoker.destroy();
- return null;
- }
-
RpcInvocation rpcInvocation = new RpcInvocation(method, invoker.getInterface().getName(), args);
rpcInvocation.setTargetServiceUniqueName(invoker.getUrl().getServiceKey());