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

[JAVA-5203] Support stored nulls for non-primitive fields in Java records #1223

Merged
merged 4 commits into from
Oct 23, 2023

Conversation

bulbfreeman
Copy link
Contributor

@bulbfreeman bulbfreeman commented Oct 16, 2023

Why

Same as the issue raised in https://jira.mongodb.org/browse/JAVA-5134, this change implements a mechanism to gracefully handle stored nulls for fields that are annotated with JSR305 @Nullable annotations.

Changes

  • Introduce a boolean field isNullable to RecordCodec.ComponentModel, which is set to true when given field is not primitive.
  • When decoding stored null for a field that is considered nullable in above step, read null in stead of throwing an BsonInvalidOperationException.
  • For any other scenarios, previous codec behaviour is preserved.

Issue ticket

JAVA-5203

@bulbfreeman bulbfreeman changed the title Support stored nulls for nullable fields in Java records [JAVA-5203] Support stored nulls for nullable fields in Java records Oct 16, 2023
Copy link
Contributor

@jyemin jyemin left a comment

Choose a reason for hiding this comment

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

Thanks for the Jira report and the pull request. I have a change request for you if you're inclined to keep working on this.

@bulbfreeman bulbfreeman changed the title [JAVA-5203] Support stored nulls for nullable fields in Java records [JAVA-5203] Support stored nulls for non-premitive fields in Java records Oct 22, 2023
@bulbfreeman bulbfreeman changed the title [JAVA-5203] Support stored nulls for non-premitive fields in Java records [JAVA-5203] Support stored nulls for non-primitive fields in Java records Oct 22, 2023
Copy link
Contributor

@jyemin jyemin left a comment

Choose a reason for hiding this comment

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

One more change, please.

@jyemin jyemin merged commit 2e12e71 into mongodb:master Oct 23, 2023
3 checks passed
@jyemin
Copy link
Contributor

jyemin commented Oct 23, 2023

Thanks for the contribution, @bulbfreeman

@bulbfreeman
Copy link
Contributor Author

OOI is there an expected date for the next version release that contains this change? @jyemin

@jyemin
Copy link
Contributor

jyemin commented Nov 3, 2023

Yes, it should be released around Tuesday of next week.

@bulbfreeman
Copy link
Contributor Author

Awesome, thanks!

@bulbfreeman bulbfreeman deleted the supportNullableInJavaRecordCodec branch November 7, 2023 06:02
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.

2 participants