spring-projects / spring-projects/spring-data-mongodb
JSpecify null validation when mapping to non-null fields in MappingMongoConverter
Open
@mp911de is already working on this.
Since Feb 23, 2026.
status: feedback-provided
status: waiting-for-triage
- Dominant language
- Java
- Stars
- 1.7k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
Since Spring Boot 4 et al, adopted JSpecify, we've been trying to null-safe our code. However, at the boundaries, nulls sneak in, and in MongoDB projections in-particular, we can end up with a null value in a non-null field JSpecify @NullMarked class or record.
Could the mapping infrastructure help us out here, rather than having a big debug session on our hands, by asserting nullness (configurable as assert x != null; (for those that want to use -ea in dev/CI/QA but not prod) or Objects.requireNonNull(x)?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.