Skip to content

Conversation

schauder
Copy link
Contributor

@schauder schauder commented Aug 26, 2025

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

Closes #1980

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

Closes #1980
@schauder schauder requested a review from mp911de August 26, 2025 12:50
@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

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

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

Choose a reason for hiding this comment

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

That's fixed.

@mp911de
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 (2025.1.0) 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.
@schauder
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 closed this Sep 4, 2025
@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
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