Skip to content

Commit 6034ceb

Browse files
beiwei30chickenlj
authored andcommitted
Merge pull request #3528, fixes #208, setOnreturn does not work with generic invocation.
1 parent 05a98f3 commit 6034ceb

File tree

2 files changed

+25
-3
lines changed
  • dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config
  • dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/filter

2 files changed

+25
-3
lines changed

dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import java.io.File;
4747
import java.io.FileInputStream;
4848
import java.io.IOException;
49+
import java.lang.reflect.Method;
4950
import java.util.ArrayList;
5051
import java.util.Arrays;
5152
import java.util.HashMap;
@@ -305,8 +306,21 @@ private void init() {
305306

306307
ref = createProxy(map);
307308

308-
ConsumerModel consumerModel = new ConsumerModel(getUniqueServiceName(), interfaceClass, ref, interfaceClass.getMethods(), attributes);
309-
ApplicationModel.initConsumerModel(getUniqueServiceName(), consumerModel);
309+
ApplicationModel.initConsumerModel(getUniqueServiceName(), buildConsumerModel(attributes));
310+
}
311+
312+
private ConsumerModel buildConsumerModel(Map<String, Object> attributes) {
313+
Method[] methods = interfaceClass.getMethods();
314+
Class serviceInterface = interfaceClass;
315+
if (interfaceClass == GenericService.class) {
316+
try {
317+
serviceInterface = Class.forName(interfaceName);
318+
methods = serviceInterface.getMethods();
319+
} catch (ClassNotFoundException e) {
320+
methods = interfaceClass.getMethods();
321+
}
322+
}
323+
return new ConsumerModel(getUniqueServiceName(), serviceInterface, ref, methods, attributes);
310324
}
311325

312326
@SuppressWarnings({"unchecked", "rawtypes", "deprecation"})

dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/filter/FutureFilter.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,22 @@ private ConsumerMethodModel.AsyncMethodInfo getAsyncMethodInfo(Invoker<?> invoke
206206
if (consumerModel == null) {
207207
return null;
208208
}
209-
ConsumerMethodModel methodModel = consumerModel.getMethodModel(invocation.getMethodName());
209+
210+
String methodName = invocation.getMethodName();
211+
if (methodName.equals(Constants.$INVOKE)) {
212+
methodName = (String) invocation.getArguments()[0];
213+
}
214+
215+
ConsumerMethodModel methodModel = consumerModel.getMethodModel(methodName);
210216
if (methodModel == null) {
211217
return null;
212218
}
219+
213220
final ConsumerMethodModel.AsyncMethodInfo asyncMethodInfo = methodModel.getAsyncInfo();
214221
if (asyncMethodInfo == null) {
215222
return null;
216223
}
224+
217225
return asyncMethodInfo;
218226
}
219227
}

0 commit comments

Comments
 (0)