Deserializing a message which is protostuff-runtime serialized and has custom class as field
GoogleCodeExporter opened this issue · comments
Here is my java message classes:
public final class Message
{
@Tag( 1 )
String field1;
@Tag( 2 )
int field2;
@Tag( 3 )
Abc abc;
public Message( String field1, int field2, Abc abc )
{
this.field1 = field1;
this.field2 = field2;
this.abc = abc;
}
}
public final class Abc
{
@Tag( 1 )
int field;
public Abc( int field )
{
this.field = field;
}
}
I build a message and serialize it into byte array via
ProtostuffIOUtil::toByteArray. Then I try to deserialize it with following
proto files:
message.proto :
option java_outer_classname = "MessageProto";
import "abc.proto";
message Message{
required string field1 = 1;
required int32 field2 = 2;
required Abc abc = 3;
}
abc.proto:
option java_outer_classname = "AbcProto";
message Abc
{
optional int32 field = 1;
}
When parsing with AbcProto.Abc.parseFrom(byteArray),
InvalidProtocolBufferException: Message missing required fields: abc is fired.
But when I use the primitive types only, it runs smoothly. Is this impossible
to do or I am doing something wrong?
I am using 1.0.8 protostuff and 2.5.0 protobuf.
Thanks.
Original issue reported on code.google.com by mty...@gmail.com
on 17 Feb 2014 at 9:25
[deleted comment]
Issue solved. ProtobufIOUtil::toByteArray should be used instead of
ProtostuffIOUtil::toByteArray.
Original comment by mty...@gmail.com
on 18 Feb 2014 at 1:55
Original comment by david.yu...@gmail.com
on 18 Feb 2014 at 2:57
- Changed state: Done