I am developing a Client-Server-application which uses Google Protocol Buffers. Unfortunatelly when I am building the protocol buffer response on the server side using the builder pattern I get a IndexOutOfBoundsException:
This is the line where I build the protobuf file:
Builder getVGResonseBuilder = App_getVGResponse.GetVGResponse.newBuilder().getVGBuilder(0);
[some more code that uses the builder patterns]
getVGResponseBuilder.set...
getVGResponseBuilder.set...
the error occures in the first line of code.
here is the protobuf definition (ofc I have compiled it! The compiled calss is App_getVGResponse):
message GetVGResponse {
message VG {
optional string id = 1;
optional string g_id = 2;
optional int64 f_id = 3;
optional string g_name = 4;
}
repeated VG v_gp = 1;
}
Here is a excerpt of my stacktrace
Exception in thread "main" com.google.protobuf.InvalidProtocolBufferException: **Protocol message tag had invalid wire type.**
at com.google.protobuf.InvalidProtocolBufferException.invalidWireType(InvalidProtocolBufferException.java:78)
at com.google.protobuf.UnknownFieldSet$Builder.mergeFieldFrom(UnknownFieldSet.java:498)
at com.google.protobuf.GeneratedMessage$Builder.parseUnknownField(GeneratedMessage.java:439)
and the debugger at runtime shows ma the variable:
e
-> cause: IndexOutOfBoundsException (id=12291)
-> detaiMessage: Index: 0, Size: 0 (id=12324)
-> stackTrace null