--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/f495283a-f62c-4458-b803-8ceef2f9e438%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
RowReply.newBuilder().setRow(Any.pack(m)).build();
However, during unpack time, I need to specify the class to unpack to and specifying DynamicMessage.class did not work.
Something like
Any any = response.getRow();
Message m = null;
if (any.is(DynamicMessage.class)){
m = any.unpack(DynamicMessage.class);
}
gave an exception
Failed to get default instance for class com.google.protobuf.DynamicMessage
Does the Any type require there being a class definition for the Message it wraps?
I also tried to use Message.class in place of DynamicMessage.class, but no success either.
Thanks.
However, during unpack time, I need to specify the class to unpack to and specifying DynamicMessage.class did not work.
Something like
Any any = response.getRow();
Message m = null;
if (any.is(DynamicMessage.class)){
m = any.unpack(DynamicMessage.class);
}
gave an exception
Failed to get default instance for class com.google.protobuf.DynamicMessage
Message m = DynamicMessage.parseFrom(descriptor, any.getValue());
Any is a tuple of (string type_url, bytes value), and here we are manually accessing the value. The descriptor you would need to determine based on any.getTypeUrl(). Any.is() is just another convenience that compares the type URL in the any to the type of the class to see if they match.
Does the Any type require there being a class definition for the Message it wraps?