Skip to content
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

[Help needed] Fix custom null serialization #182

Open
wants to merge 1 commit into
base: 2.10
Choose a base branch
from
Open

[Help needed] Fix custom null serialization #182

wants to merge 1 commit into from

Conversation

marcospassos
Copy link
Contributor

@cowtowncoder implementing a null custom serialization for an internal library, I stumbled upon a bug that prevents serialized null from being deserialized (which should affect other packages, such as JSR-353). For now, this PR only includes a test that reproduces the problem.

Error message:

com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input

Could you give me some guidance on how to fix it?

final JsonParser parser,
final DeserializationContext context
) throws IOException {
parser.nextToken();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not right: should instead check that current token is JsonToken.VALUE_NULL: parser already points to the first token of value to deserialize.

@cowtowncoder
Copy link
Member

It'd be good to maybe file issue separately, link to/from this PR.
There's one small problem with custom deserializer, not sure if it matters.

@marcospassos
Copy link
Contributor Author

marcospassos commented Sep 26, 2019

It'd be good to maybe file issue separately, link to/from this PR.

I'll open a PR.

I just pushed a new commit, but it doesn't seem to fix the issue.

@marcospassos
Copy link
Contributor Author

marcospassos commented Sep 26, 2019

Additional info: the same does not happen when serializing/deserializing to/from JSON.

@cowtowncoder
Copy link
Member

Ok. Thank you for verifying.

I think this could be related to one oddity wrt Avro handling of nulls: unless null value is part of union, it "does not exist": that is, it does not take any space. Value of a field with only null type is always null, and nothing is encoded.
This is fine in theory, but presents unique problem at root-level reader: it is not easy to know if stream has ended or not -- just because there are no bytes left does not necessarily mean we are done as null may still be implicitly available!
(I had to fix one bug earlier related to this).

@marcospassos
Copy link
Contributor Author

Dammit, now I see why I couldn't find an easy way to fix it myself without consuming your limited time. But it seems a critical bug to fix, as it can break things seriously. Again, let me know if I can help you fix it.

@cowtowncoder
Copy link
Member

@marcospassos Unfortunately I do not really have time to work on this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants