spring-projects / spring-projects/spring-data-mongodb

JSpecify null validation when mapping to non-null fields in MappingMongoConverter

Open
#5,167 3 comments 0 reactions 1 assignee View on GitHub

@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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.