/** * Decode the a protobuf from the given input stream * @param builder - Builder of the protobuf to decode * @param dis - DataInputStream to read the protobuf * @return Message - decoded protobuf * @throws WrappedRpcServerException - deserialization failed */ @SuppressWarnings("unchecked") private <T extends Message> T decodeProtobufFromStream(Builder builder, DataInputStream dis) throws WrappedRpcServerException { try { builder.mergeDelimitedFrom(dis); return (T)builder.build(); } catch (Exception ioe) { Class<?> protoClass = builder.getDefaultInstanceForType().getClass(); throw new WrappedRpcServerException( RpcErrorCodeProto.FATAL_DESERIALIZING_REQUEST, "Error decoding " + protoClass.getSimpleName() + ": "+ ioe); } }
/** * Decode the a protobuf from the given input stream * @param builder - Builder of the protobuf to decode * @param dis - DataInputStream to read the protobuf * @return Message - decoded protobuf * @throws WrappedRpcServerException - deserialization failed */ @SuppressWarnings("unchecked") private <T extends Message> T decodeProtobufFromStream(Builder builder, DataInputStream dis) throws WrappedRpcServerException { try { builder.mergeDelimitedFrom(dis); return (T)builder.build(); } catch (Exception ioe) { Class<?> protoClass = builder.getDefaultInstanceForType().getClass(); throw new WrappedRpcServerException( RpcErrorCodeProto.FATAL_DESERIALIZING_REQUEST, "Error decoding " + protoClass.getSimpleName() + ": "+ ioe); } }
builder.mergeDelimitedFrom(in); Message value = builder.build();