Skip to content

Conversation

@ericbottard
Copy link
Member

Configure ErrorProne + NullAway on the codebase.

Fix various ErrorProne issues across the codebase.

This is the first step towards implementing JSpecify null safety gradually.
This first commit focuses solely on setting up ErrorProne. In doing so, it caught a handful
of issues with our tests, that this commit fixes.

There are also many warnings that may be of interest.

Copy link
Contributor

@sdeleuze sdeleuze left a comment

Choose a reason for hiding this comment

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

As discussed today, it could make sense at least initially to configure NullAway to only check null-marked code via -XepOpt:NullAway:OnlyNullMarked as done in this PR, that will allow to introduce null-safety annotations package by package.

We typically only enable null-safety checks with Error Prone to avoid slowing down the compilation too much and don't confuse contributors with other kind of checks. This kind be done by specifying -XepDisableAllChecks (which was already used on Gradle side). This was not configured in the maven branch of my jspecify-nullaway-demo project, it is now fixed, so maybe Spring AI could do the same, but as you prefer.

NullAway requires a recent version of javac, this is enforced by NullAway in recent versions, and due to the forked compiler, it looks like the NullAway error message is not visible when using an unsupported Java version, so I would advise to use the Maven enforcer plugin to ensure Java 25 is used (combined with the existing --release 17 to keep the baseline). The CI configuration should be updated to use Java 25 as well on main. You can maybe take inspiration of Spring Data build .

@ericbottard ericbottard added this to the 2.0.0.M1 milestone Nov 19, 2025
@ericbottard
Copy link
Member Author

Requires #4916 to be merged first. I'll rebase this on main when this is done

Fix various ErrorProne issues across the codebase.

Signed-off-by: Eric Bottard <[email protected]>
@ericbottard ericbottard force-pushed the error-prone branch 2 times, most recently from 5ffc0e2 to c430a00 Compare November 19, 2025 17:24
@ericbottard ericbottard merged commit c08409f into spring-projects:main Nov 20, 2025
2 checks passed
@ericbottard ericbottard self-assigned this Nov 20, 2025
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