From 6034ceb21af7c34ef1778dad9a41b6ffa67667b6 Mon Sep 17 00:00:00 2001 From: Ian Luo Date: Tue, 26 Feb 2019 09:52:56 +0800 Subject: [PATCH] Merge pull request #3528, fixes #208, setOnreturn does not work with generic invocation. --- .../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; } }