ProtobufRpcMethodInfo extends RpcMethodInfo { @Override public int getInputSerializedSize(Object input) throws IOException { if (input instanceof Message) { return ((Message) input).getSerializedSize(); } return 0; } ProtobufRpcMethodInfo(Method method); @Override byte[] inputEncode(Object input); @Override void inputWriteToStream(Object input, CodedOutputStream stream); @Override Object outputDecode(byte[] output); @Override Object outputDecode(ByteBuf output); @Override Object outputDecode(DynamicCompositeByteBuf output); Object outputDecode(InputStream stream); Object inputDecode(byte[] input); Object inputDecode(byte[] input, int offset, int len); Object inputDecode(ByteBuf input); Object inputDecode(DynamicCompositeByteBuf input); Object inputDecode(InputStream stream); byte[] outputEncode(Object output); @Override void outputWriteToStream(Object output, CodedOutputStream stream); @Override int getInputSerializedSize(Object input); @Override int getOutputSerializedSize(Object output);  }
@Test public void testGetInputSerializedSize() throws Exception { Method method = EchoService.class.getMethod("echo", Echo.EchoRequest.class); ProtobufRpcMethodInfo rpcMethodInfo = new ProtobufRpcMethodInfo(method); Echo.EchoRequest request = Echo.EchoRequest.newBuilder().setMessage("hello").build(); Assert.assertTrue(rpcMethodInfo.getInputSerializedSize(request) == request.getSerializedSize()); }