On Thu, Feb 9, 2012 at 03:33, MohanR <[email protected]> wrote:
> Hi,
>         I tried to write and read a simple '.proto' structure but
> when I read it back I get an exception. Is there something wrong with
> the way I read ?
>
>
> Thanks.
>
> --------------proto-------------
>
> package message;
>
> message Load {
>
>  enum LoadType {
>    HIGH = 0;
>    MEDIUM = 1;
>    LOW = 2;
>  }
>  message LoadBalance {
>    optional LoadType type = 2 [default = MEDIUM];
>  }
>  optional LoadBalance loadbalancer = 1;
> }
>
> -------------Write-----------
>
>        Message.Load message =
> Message.Load.newBuilder().setLoadbalancer(
>
> Message.Load.LoadBalance.newBuilder().setType( 
> Message.Load.LoadType.HIGH)).build();

uhm, where do you set the value ? I'd expected something like
SerializeToString()
>
> ------------Read----------
>
>            Message.Load message = Message.Load.parseFrom( value );
>
> -----------Exception--------
>
> InvalidProtocolBufferExceptionProtocol message contained an invalid
> tag (zero).
> com.google.protobuf.InvalidProtocolBufferException: Protocol message
> contained an invalid tag (zero).
>        at
> com.google.protobuf.InvalidProtocolBufferException.invalidTag(InvalidProtocolBufferException.java:
> 68)
>        at com.google.protobuf.CodedInputStream.readTag(CodedInputStream.java:
> 108)
>        at message.Message$Load$Builder.mergeFrom(Message.java:723)
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Protocol Buffers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/protobuf?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to