From b88c55f93bcd2da0609654b49e3c10907c527345 Mon Sep 17 00:00:00 2001 From: Ian Luo Date: Thu, 21 Feb 2019 15:13:42 +0800 Subject: [PATCH] =?UTF-8?q?fix=20issue=20#208:=20=E5=BC=82=E6=AD=A5?= =?UTF-8?q?=E6=B3=9B=E5=8C=96=E8=B0=83=E7=94=A8=E8=AE=BE=E7=BD=AEsetOnretu?= =?UTF-8?q?rn=E6=97=A0=E6=95=88=202.5.3=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apache/dubbo/config/ReferenceConfig.java | 18 ++++++++++++++++-- .../protocol/dubbo/filter/FutureFilter.java | 10 +++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java index 71d05739a1d..659b46d674b 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java @@ -46,6 +46,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -305,8 +306,21 @@ private void init() { ref = createProxy(map); - ConsumerModel consumerModel = new ConsumerModel(getUniqueServiceName(), interfaceClass, ref, interfaceClass.getMethods(), attributes); - ApplicationModel.initConsumerModel(getUniqueServiceName(), consumerModel); + ApplicationModel.initConsumerModel(getUniqueServiceName(), buildConsumerModel(attributes)); + } + + private ConsumerModel buildConsumerModel(Map attributes) { + Method[] methods = interfaceClass.getMethods(); + Class serviceInterface = interfaceClass; + if (interfaceClass == GenericService.class) { + try { + serviceInterface = Class.forName(interfaceName); + methods = serviceInterface.getMethods(); + } catch (ClassNotFoundException e) { + methods = interfaceClass.getMethods(); + } + } + return new ConsumerModel(getUniqueServiceName(), serviceInterface, ref, methods, attributes); } @SuppressWarnings({"unchecked", "rawtypes", "deprecation"}) diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/filter/FutureFilter.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/filter/FutureFilter.java index a4c6b09c5de..98283f450c8 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/filter/FutureFilter.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/filter/FutureFilter.java @@ -206,14 +206,22 @@ private ConsumerMethodModel.AsyncMethodInfo getAsyncMethodInfo(Invoker invoke if (consumerModel == null) { return null; } - ConsumerMethodModel methodModel = consumerModel.getMethodModel(invocation.getMethodName()); + + String methodName = invocation.getMethodName(); + if (methodName.equals(Constants.$INVOKE)) { + methodName = (String) invocation.getArguments()[0]; + } + + ConsumerMethodModel methodModel = consumerModel.getMethodModel(methodName); if (methodModel == null) { return null; } + final ConsumerMethodModel.AsyncMethodInfo asyncMethodInfo = methodModel.getAsyncInfo(); if (asyncMethodInfo == null) { return null; } + return asyncMethodInfo; } }