cleanup(gax-java): remove javax.annotation.Nonnull usage - #13959
cleanup(gax-java): remove javax.annotation.Nonnull usage#13959nnicolee wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request removes the @Nonnull annotation and its corresponding javax.annotation.Nonnull import across numerous files in the gax-java library, likely as part of a migration to JSpecify annotations. A review of the changes identified a redundant null check in ServerStreamingCallSettings.java where Preconditions.checkNotNull(resumptionStrategy) is called twice consecutively, which should be simplified.
| Preconditions.checkNotNull(resumptionStrategy); | ||
| this.resumptionStrategy = Preconditions.checkNotNull(resumptionStrategy); |
There was a problem hiding this comment.
The null check Preconditions.checkNotNull(resumptionStrategy) is performed twice in a row. We can simplify this by directly assigning the result of Preconditions.checkNotNull(resumptionStrategy) to this.resumptionStrategy.
| Preconditions.checkNotNull(resumptionStrategy); | |
| this.resumptionStrategy = Preconditions.checkNotNull(resumptionStrategy); | |
| this.resumptionStrategy = Preconditions.checkNotNull(resumptionStrategy); |
References
- Ensure that null checks and validation steps are not redundant with checks already performed by upstream callers or preceding logic in the same method.
|
|





This PR removes all occurrences of
javax.annotation.Nonnull(both imports and annotations) across thegax-javacodebase.Why this change is needed:
As part of the repository-wide migration to JSpecify annotations, classes are annotated with
@NullMarked, making all unannotated types non-nullable by default. The legacyjavax.annotation.Nonnullannotations are redundant and can be safely removed without changing null-safety semantics.Changes:
import javax.annotation.Nonnull;and@Nonnullfrom 30 files acrossgax,gax-grpc, andgax-httpjson(including test files).fmt-maven-plugin.javax.annotation.Nonnullundergax-javahave been eliminated.