1 year ago

#336063

test-img

keyboard_smasher

Cannot convert byte array back to Protobuf String

    @Test
    public void test() throws InvalidProtocolBufferException {
        byte[] testString = StringValue.newBuilder()
                                       .setValue("testString")
                                       .build()
                                       .getValueBytes()
                                       .toByteArray();

        StringValue stringValue = StringValue.parseFrom(testString);
        System.out.println(stringValue);
    }

Created a byte array from the Protobuf StringValue, but when converted it back, I got:

com.google.protobuf.InvalidProtocolBufferException: Protocol message end-group tag did not match expected tag.

Any idea why would this happen?

protobuf-java

0 Answers

Your Answer

Accepted video resources