-
Notifications
You must be signed in to change notification settings - Fork 368
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
Conversation
Replace nullability annotations with their JSpecify equivalents. Enable checking this annotations at compile time using Errorprone and NullAway. Closes #1980
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fixed.
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.
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.
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.
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
Uh oh!
There was an error while loading. Please reload this page.
Replace nullability annotations with their JSpecify equivalents.
Enable checking this annotations at compile time using Errorprone and NullAway.
Closes #1980