if (methodDescriptor == null) {
throw new RemoteCallException(request.getId(),
new NoSuchMethodException(methodName));
}
Message paramProto = null;
if (request.hasRequestMessage()) {
try {
paramProto = service.getRequestPrototype(methodDescriptor)
.newBuilderForType().mergeFrom(request.getRequestMessage()).
build();
} catch (Throwable t) {
throw new RemoteCallException(request.getId(), methodDescriptor, t);
}
}
Message returnValue;
RpcController controller = new NettyRpcController();
try {
returnValue = service.callBlockingMethod(methodDescriptor,
controller, paramProto);
} catch (Throwable t) {
throw new RemoteCallException(request.getId(), methodDescriptor, t);
}
RpcResponse.Builder builder =
RpcResponse.newBuilder().setId(request.getId());
if (returnValue != null) {
builder.setResponseMessage(returnValue.toByteString());
}
if (controller.failed()) {
builder.setErrorMessage(controller.errorText());
}