Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue #208: 异步泛化调用设置setOnreturn无效 2.5.3版本 #3528

Merged
merged 1 commit into from
Feb 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}