Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Migrate to JSpecify annotations for nullability constraints #2126

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

Closed
schauder wants to merge 5 commits into main from issue/1980-jspecify

Conversation

Copy link
Contributor

@schauder schauder commented Aug 26, 2025
edited
Loading

Replace nullability annotations with their JSpecify equivalents.
Enable checking this annotations at compile time using Errorprone and NullAway.

Closes #1980

chanhyeong reacted with thumbs up emoji
Replace nullability annotations with their JSpecify equivalents.
Enable checking this annotations at compile time using Errorprone and NullAway.
Closes #1980 
@mp911de mp911de added the type: enhancement A general enhancement label Sep 2, 2025
@mp911de mp911de self-assigned this Sep 2, 2025
@@ -42,64 +42,41 @@
*/
public interface DbAction<T> {

Class<T> getEntityType();
Class<T> entityType();
Copy link
Member

@mp911de mp911de Sep 2, 2025

Choose a reason for hiding this comment

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

DbAction is a public API. We should not introduce breaking changes without deprecation. Was this change intended?

Copy link
Contributor Author

@schauder schauder Sep 2, 2025

Choose a reason for hiding this comment

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

That is absolutely an accident.

Copy link
Contributor Author

@schauder schauder Sep 3, 2025

Choose a reason for hiding this comment

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

That's fixed.

Copy link
Member

mp911de commented Sep 2, 2025

RelationalEntityWriterUnitTests.cascadingReferencesTriggerCascadingActions fails with:


org.opentest4j.AssertionFailedError: 
Expecting actual:
 [(org.springframework.data.relational.core.conversion.DbAction.InsertRoot, org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.CascadingReferenceEntity, "", org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.CascadingReferenceEntity, false, GENERATED),
 (org.springframework.data.relational.core.conversion.DbAction.Insert, org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.CascadingReferenceMiddleElement, "other", org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.CascadingReferenceMiddleElement, true, GENERATED),
 (org.springframework.data.relational.core.conversion.DbAction.Insert, org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.CascadingReferenceMiddleElement, "other", org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.CascadingReferenceMiddleElement, true, GENERATED),
 (org.springframework.data.relational.core.conversion.DbAction.Insert, org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.Element, "other.element", org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.Element, true, GENERATED),
 (org.springframework.data.relational.core.conversion.DbAction.Insert, org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.Element, "other.element", org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.Element, true, GENERATED)]
to contain exactly (and in same order):
 [(org.springframework.data.relational.core.conversion.DbAction.InsertRoot, org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.CascadingReferenceEntity, "", org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.CascadingReferenceEntity, false, GENERATED),
 (org.springframework.data.relational.core.conversion.DbAction.Insert, org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.CascadingReferenceMiddleElement, "other", org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.CascadingReferenceMiddleElement, true, GENERATED),
 (org.springframework.data.relational.core.conversion.DbAction.Insert, org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.CascadingReferenceMiddleElement, "other", org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.CascadingReferenceMiddleElement, true, GENERATED),
 (org.springframework.data.relational.core.conversion.DbAction.Insert, org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.Element, "other.element", org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.Element, true, GENERATED),
 (org.springframework.data.relational.core.conversion.DbAction.Insert, org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.Element, "other.element", org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.Element, true, GENERATED),
 (org.springframework.data.relational.core.conversion.DbAction.Insert, org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.Element, "other.element", org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.Element, true, GENERATED),
 (org.springframework.data.relational.core.conversion.DbAction.Insert, org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.Element, "other.element", org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.Element, true, GENERATED)]
but could not find the following elements:
 [(org.springframework.data.relational.core.conversion.DbAction.Insert, org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.Element, "other.element", org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.Element, true, GENERATED),
 (org.springframework.data.relational.core.conversion.DbAction.Insert, org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.Element, "other.element", org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.Element, true, GENERATED)]
Expected :[(org.springframework.data.relational.core.conversion.DbAction.InsertRoot, org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.CascadingReferenceEntity, "", org.springframework.data.relational.core.conversion.Relationa ...
Actual :[(org.springframework.data.relational.core.conversion.DbAction.InsertRoot, org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.CascadingReferenceEntity, "", org.springframework.data.relational.core.conversion.Relationa ...
<Click to see difference>
	at org.springframework.data.relational.core.conversion.RelationalEntityWriterUnitTests.cascadingReferencesTriggerCascadingActions(RelationalEntityWriterUnitTests.java:332)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

and two other test methods in the same class. Care to have a look?

Refine nullability annotation formatting, reduce warnings (final fields, isEmpty vs. length() == null), introduce getRequired...() methods to avoid Assert sprawl. Convert internal classes to records. Fix generic types (refactoring leftovers).
Replace package-info imports with fully-qualified annotation name to align formatting.
@mp911de mp911de added this to the 4.0 M6 (202510) milestone Sep 2, 2025
@mp911de mp911de changed the title (削除) Migrate to JSpecify annotations for nullability constraints. (削除ここまで) (追記) Migrate to JSpecify annotations for nullability constraints (追記ここまで) Sep 2, 2025
a class used in the tests was converted to records. The problem: It was used in a set and the equals/hashCode implementation of record made all instances the same.
Copy link
Contributor Author

schauder commented Sep 3, 2025

RelationalEntityWriterUnitTests.cascadingReferencesTriggerCascadingActions fails with:
...
and two other test methods in the same class. Care to have a look?

That's fixed. A conversion to record made instances in a Set identical. Reverted the change.

mp911de pushed a commit that referenced this pull request Sep 4, 2025
Replace nullability annotations with their JSpecify equivalents.
Enable checking this annotations at compile time using Errorprone and NullAway.
Closes #1980
Original pull request: #2126 
mp911de added a commit that referenced this pull request Sep 4, 2025
Refine nullability annotation formatting, reduce warnings (final fields, isEmpty vs. length() == null), introduce getRequired...() methods to avoid Assert sprawl. Convert internal classes to records. Fix generic types (refactoring leftovers).
Replace package-info imports with fully-qualified annotation name to align formatting.
See #1980
Original pull request: #2126 
@mp911de mp911de deleted the issue/1980-jspecify branch September 4, 2025 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@mp911de mp911de mp911de left review comments

Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate to JSpecify annotations for nullability constraints
2 participants

AltStyle によって変換されたページ (->オリジナル) /