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

源码疑问,getGrpcClient 获取stub疑问 #18

Closed
dengqx520 opened this issue Sep 4, 2017 · 0 comments
Closed

源码疑问,getGrpcClient 获取stub疑问 #18

dengqx520 opened this issue Sep 4, 2017 · 0 comments

Comments

@dengqx520
Copy link

获取stub时判断了StringUtils.contains(stubClassName, "$"),但是我看到生成的class没有$符号

public AbstractStub getGrpcClient(ChannelCall channelPool, int callType, int callTimeout) {
String stubClassName = GrpcStubClient.this.getStubClassName();
Channel channel = null;
if (StringUtils.contains(stubClassName, "$")) {
try {
String parentName = StringUtils.substringBefore(stubClassName, "$");
Class<?> clzz = ReflectUtils.name2class(parentName);
Method method;
switch (callType) {
case Constants.RPCTYPE_ASYNC:
method = clzz.getMethod("newFutureStub", io.grpc.Channel.class);
break;
case Constants.RPCTYPE_BLOCKING:
method = clzz.getMethod("newBlockingStub", io.grpc.Channel.class);
break;
default:
method = clzz.getMethod("newFutureStub", io.grpc.Channel.class);
break;
}
channel = channelPool.borrowChannel(refUrl);
AbstractStub stubInstance = (AbstractStub) method.invoke(null, channel);
return stubInstance;
} catch (Exception e) {
throw new IllegalArgumentException(
"stub definition not correct,do not edit proto generat file", e);
} finally {
if (channel != null) {
channelPool.returnChannel(refUrl, channel);
}
}
} else {
throw new IllegalArgumentException(
"stub definition not correct,do not edit proto generat file");
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant