-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
Honor READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE
feature with Protobuf
#398
Comments
READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE
feature with Protobuf
This makes sense from functionality perspective, +1. One challenge is that of exposing "unknown" value: parser has no way to access information at databind level so there'd have to be some convention of passing maybe marker value (empty String? -1?), or perhaps As with other ideas this could be configurable with a new It might also possible to change some of handling of |
Thanks for your reply. The way the wire plugin resolve this is that they default on the position 0 when the enum not found. Let's say you have the following schema:
With no option to fall-back if the upstream server send the value at index 2 or 4 and above it will fail as expected with a With the feature |
@itsmoonrack That makes sense to me, yes. |
Also realized now that |
Ha you are right, good point. |
The wire plugin uses a mechanism of fall-back to default enum value (index 0) when the index is above the one in the schema, this ensure we don't break compatibility when they add a new field upstream, our system still can deserialize the message by fall-back on the default value. Of course some systems want that an exception be thrown when encountering an unknown value.
This behaviour could be setup (enabled or disabled) through the standard DeserializationFeature: READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE
if true we fall-back on the default enum value (index 0) and if false we throw an exception.
The text was updated successfully, but these errors were encountered: