Skip to content

Conversation

@bamapookie
Copy link

@bamapookie bamapookie commented Oct 6, 2025

  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

Copyright date already set to 2025. No new files. No author lists in files I touched, so I left my name out.

Fixes #5065

Copy link
Member

@christophstrobl christophstrobl left a comment

Choose a reason for hiding this comment

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

Thank you for taking the time to prepare this PR.
Kindly let me know if you'd like to add the tests from the review comment. If not, I can take it from here and continue the work.

@Test // GH-5065
@DisplayName("Converter should read an empty object as an empty map with a valis values property when using @DocumentReference(lazy = true).")
void readsEmptyMapWithLazyLoadedDocumentReferenceCorrectly() {
org.bson.Document document = org.bson.Document.parse("{\"map\":{}}");
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 it would also be interesting to have test for { 'map' : null } expecting null for the target.map.

@bamapookie
Copy link
Author

bamapookie commented Oct 15, 2025 via email

@bamapookie bamapookie force-pushed the 5065-empty-map-with-document-reference branch from 18d87d6 to dbda7b4 Compare October 16, 2025 04:46
@bamapookie
Copy link
Author

bamapookie commented Oct 16, 2025

I added tests where the map is explicitly assigned null and rebased on the latest main. There is one error occurring on the null assignment to the @DocumentReference Map<>. I also added @DBRef tests as well, though I don't think they are affected by the underlying bug. I'll look into the failing test tomorrow.

@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 20, 2025
@mp911de mp911de requested a review from schauder October 20, 2025 13:47
Copy link
Contributor

@schauder schauder left a comment

Choose a reason for hiding this comment

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

I left a couple of comments.


@Test // GH-5065
@DisplayName("Converter should read an explicitly assigned null as a null map when using @DocumentReference.")
void readsExplicitlyNullMapWithDocumentReferenceCorrectly() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test fails for me with

org.springframework.data.mapping.MappingException: Couldn't find PersistentEntity for type class java.lang.String

Might be the one you referred to in your last comment.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, this is the new test for the new failure I mentioned in the ticket. I have not had a chance to resolve it yet.

Copy link
Author

Choose a reason for hiding this comment

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

I split the test into the 2 separate checks, then duplicated the tests for sets and lists. The bug is there for lists and sets. I also added the control tests back in to show that non-DocumentReferences behave correctly.

@bamapookie bamapookie force-pushed the 5065-empty-map-with-document-reference branch from e4a7ec6 to ffb14f2 Compare October 30, 2025 02:08
bamapookie and others added 8 commits October 31, 2025 00:47
Signed-off-by: Shawn Kovalchick <bamapookie@gmail.com>
Signed-off-by: Shawn Kovalchick <bamapookie@gmail.com>
…o prevent lazy proxy handling between tests

Signed-off-by: Shawn Kovalchick <bamapookie@gmail.com>
Signed-off-by: Shawn Kovalchick <bamapookie@gmail.com>
Signed-off-by: Shawn Kovalchick <bamapookie@gmail.com>
Signed-off-by: Shawn Kovalchick <bamapookie@gmail.com>
Signed-off-by: Shawn Kovalchick <bamapookie@gmail.com>
Added back in the control tests

Signed-off-by: Shawn Kovalchick <bamapookie@gmail.com>
@bamapookie bamapookie force-pushed the 5065-empty-map-with-document-reference branch from ffb14f2 to fbdb746 Compare October 31, 2025 04:48
@schauder
Copy link
Contributor

schauder commented Nov 3, 2025

Are you still looking in the failing tests, or should we take over?

@schauder schauder added the status: waiting-for-feedback We need additional information before we can continue label Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-feedback We need additional information before we can continue type: bug A general bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document with Map decorated with @NonNull and @DocumentReference fails to deserialize

5 participants