Skip to content

Commit

Permalink
Merge pull request #3528, fixes #208, setOnreturn does not work with …
Browse files Browse the repository at this point in the history
…generic invocation.
  • Loading branch information
beiwei30 authored and chickenlj committed Feb 26, 2019
1 parent 05a98f3 commit 6034ceb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, Object> 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"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 6034ceb

Please sign in to comment.