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

NPE when using Standard serializer implementation for serializing {link java.util.Map} types #1439

Closed
thomasKlug opened this issue Oct 31, 2016 · 2 comments
Milestone

Comments

@thomasKlug
Copy link

Utilizing jackson-databind-2.7.5.

There seems to be an issue surrounding the _filterId when serializing a Map. The Implementation we are setting a default filter by overriding, the JacksonAnnotationIntrospector findFilterId. A default filterId is set if one is not found. That Id may or may not be found, so we set the SimpleFilterProvider().setFailOnUnknownId to false. However in the Implementation of the MapSerializer there is an issue within the serialize method specifically

if (_filterId != null) {
                serializeFilteredFields(value, gen, provider,
                        findPropertyFilter(provider, _filterId, value), suppressableValue);
            } else if (suppressableValue != null) {
                serializeOptionalFields(value, gen, provider, suppressableValue);
            } else if (_valueSerializer != null) {
                serializeFieldsUsing(value, gen, provider, _valueSerializer);
            } else {
                serializeFields(value, gen, provider);
            }

Since the above code block assumes that the filter will be found, null gets passed into serializeFilteredFields resulting in an NPE.

The above I believe could be written:

if (_filterId != null && findPropertyFilter(provider, _filterId, value) != null) {
                serializeFilteredFields(value, gen, provider,
                        findPropertyFilter(provider, _filterId, value), suppressableValue);
            } else if (suppressableValue != null) {
                serializeOptionalFields(value, gen, provider, suppressableValue);
            } else if (_valueSerializer != null) {
                serializeFieldsUsing(value, gen, provider, _valueSerializer);
            } else {
                serializeFields(value, gen, provider);
            }
@cowtowncoder cowtowncoder added this to the 2.7.9 milestone Nov 2, 2016
@cowtowncoder
Copy link
Member

Thanks, will fix.

@cowtowncoder
Copy link
Member

Fixed for 2.7.9 / 2.8.5; of these latter is likely to be released sooner (and for 2.7, 2.7.9 may be the last patch).

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

No branches or pull requests

2 participants