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

Fix property value conversion in query mapper for nested values. #4517

Closed
wants to merge 4 commits into from

Conversation

christophstrobl
Copy link
Member

@christophstrobl christophstrobl commented Sep 28, 2023

Resolves: #4510

@@ -455,6 +455,15 @@ public <T> T getPropertyValue(MongoPersistentProperty property) {
return collection.stream().map(it -> valueConverter.write(it, conversionContext)).collect(Collectors.toList());
}

if(!documentField.getProperty().isMap() && sourceValue instanceof Document document) {
return new Document(document.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey(), entry -> {
Copy link

Choose a reason for hiding this comment

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

minor suggestion: .collect(Collectors.toMap(Entry::getKey, entry -> {

Copy link
Member Author

Choose a reason for hiding this comment

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

We had a second look and using the stream API here bears some risks. Entry order may not be preserved and the usage of Collectors API can cause NPE due to JDK-8148463.

mp911de pushed a commit that referenced this pull request Feb 12, 2024
mp911de added a commit that referenced this pull request Feb 12, 2024
Refine nullability declarations and NPE guards. Reformat code.

See #4510
Original pull request: #4517
@mp911de mp911de closed this Feb 12, 2024
@mp911de mp911de deleted the issue/4510 branch February 12, 2024 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

QueryMapper with annotations and does not properly applies PropertyValueConverter
4 participants