Skip to content

Fix NPE when reading/mapping null value inside collection. #3691

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

Closed
wants to merge 2 commits into from

Conversation

christophstrobl
Copy link
Member

Closes: #3686

public <S extends Object> S convert(Object source, TypeInformation<? extends S> typeHint) {
public <S extends Object> S convert(@Nullable Object source, TypeInformation<? extends S> typeHint) {

if(source == null) {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't that be rather caught in the map and collection iterations as we basically make convert nullable?

Copy link
Member Author

Choose a reason for hiding this comment

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

The MappingMongoConverter does not follow the o.s.c.c.converter.Converter contract and accepted null in previous versions, though the documentation did state it differently. Since it's a public API, I'd rather restore the original behaviour and alter the documentation, than spread null checks in various places.

@mp911de mp911de deleted the issue/3686 branch September 21, 2021 12:59
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

Successfully merging this pull request may close these issues.

reading a document with a list with a null element fails with Spring Data Mongo 3.2.2, works with 3.2.1
2 participants