-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enums defined in proto2
throws an exception
#8
Comments
Hi @jrhee17 - upstream defined JSON serialization for protobuf only in https://developers.google.com/protocol-buffers/docs/proto3#json So this project only targets proto3 primarily and proto2 support is best effort. It was definitely quite intentional to use only numeric value setting for enums from the byte-buddy generated code because having to reference the actual Java class for the enum makes things much trickier. |
…ion failure (#4033) Motivation: Currently, armeria server fails to start up while trying to create a `MessageMarshaller` for `proto2` files containing `Enum` definitions. It seems like [protobuf-jackson](curioswitch/protobuf-jackson#8) doesn't support `proto2`. However, it seems like upstream at least partially supports `proto2`. https://developers.google.com/protocol-buffers/docs/reference/java/com/google/protobuf/util/JsonFormat > The JSON format follows Proto3 JSON specification and only proto3 features are supported. Proto2 only features (e.g., extensions and unknown fields) will be discarded in the conversion. That is, when converting proto2 messages to JSON format, extensions and unknown fields will be treated as if they do not exist. This applies to proto2 messages embedded in proto3 messages as well. Modifications: - Introduce a `GsonGrpcJsonMarshaller` which performs JSON marshalling using Gson. - Also introduce a corresponding builder class `GrpcJsonMarshallerBuilder` - Add `GrpcJsonMarshaller#ofJackson`, `GrpcJsonMarshaller#builderForJackson`, `GrpcJsonMarshaller#ofGson`, `GrpcJsonMarshaller#builderForGson` Result: - Closes #4020 - Armeria now provides an easy way to fall back to the upstream `gson` implementation
When one tries to deserialize json into
proto2
with enums defined, an exception seems to be thrown.This behavior seems to differ from upstream, since only
proto2
specific features aren't supported.I haven't gone through the code so I'm unsure how trivial the fix will be, but wanted to file an issue to record my findings.
If one defines an enum in
proto2
And tries to parse
json
intoproto
the following exception is thrown
It seems like
proto2
generates stubs differently for enumsThe text was updated successfully, but these errors were encountered: