Skip to content

cleanup(gax-java): remove javax.annotation.Nonnull usage - #13959

Merged
nnicolee merged 4 commits into
mainfrom
cleanup/gax-remove-javax-nonnull
Aug 6, 2026
Merged

cleanup(gax-java): remove javax.annotation.Nonnull usage#13959
nnicolee merged 4 commits into
mainfrom
cleanup/gax-remove-javax-nonnull

Conversation

@nnicolee

@nnicolee nnicolee commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

This PR removes all occurrences of legacy javax.annotation.Nonnull annotations and imports across the gax-java codebase, removes the unused jsr305 dependency, and corrects misplaced/incorrect nullability annotations in the core modules (gax, gax-grpc, and gax-httpjson).

Why this change is needed:

As part of the repository-wide migration to JSpecify annotations, packages/classes are annotated with @NullMarked, making all unannotated types non-nullable by default.

  • The legacy javax.annotation.Nonnull annotations are redundant under JSpecify semantics and can be safely removed.
  • Resolving misplaced nullability signatures and aligning overridden methods enables compilation checks under NullAway static analysis with JSpecifyMode=true.

JSR-305 (jsr305) Dependency Removal:

We removed the com.google.code.findbugs:jsr305 dependency from the pom.xml files. This is not a breaking change for the following reasons:

  • Why it was removed: Because we removed all references to the javax.annotation package in the codebase, the Maven dependency analyzer (mvn dependency:analyze) flagged jsr305 as an unused declared dependency. Since our verification fails on any warning (-DfailOnWarning=true), the dependency had to be removed to pass presubmit checks.
  • Why it's not a breaking change: The dependency was declared with provided scope, meaning it was only used during compilation and was never distributed transitively to downstream users. Removing it has no runtime impact on library consumers.

Changes:

  • Removed import javax.annotation.Nonnull; and @Nonnull from 30 files across gax, gax-grpc, and gax-httpjson (including test files).
  • Migrated remaining javax.annotation.Nullable usages in tests to JSpecify's @Nullable type-use annotation.
  • Removed the unused jsr305 dependency from the gax-java module POMs.
  • Fixed type-use annotation placements and annotate missing annotations
  • Formatted all modified files using fmt-maven-plugin.
  • Verified that all compilation and dependency analysis stages pass cleanly.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@nnicolee
nnicolee requested a review from lqiu96 July 30, 2026 16:14
Comment thread sdk-platform-java/gax-java/gax/pom.xml
Comment thread sdk-platform-java/gax-java/gax-grpc/pom.xml
@lqiu96

lqiu96 commented Aug 3, 2026

Copy link
Copy Markdown
Member

@nnicolee I think there are a few straggling instances I've seen with @Nullable being in the wrong spot from doing a spot check:

Can you take a look? I think we can also raise a new PR to do additional cleanup

@lqiu96

lqiu96 commented Aug 3, 2026

Copy link
Copy Markdown
Member

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request migrates the codebase from JSR-305 nullness annotations (@nonnull, @nullable) to JSpecify annotations (@nullable, @NullMarked). It removes the jsr305 dependency from the Maven POM files across multiple modules (gax-grpc, gax-httpjson, and gax) and updates the Java source files by removing @nonnull annotations (relying on class-level @NullMarked instead) and shifting @nullable annotations to type-use positions. There are no review comments to address, and I have no additional feedback to provide.

@nnicolee
nnicolee force-pushed the cleanup/gax-remove-javax-nonnull branch from 7619775 to 5fe253d Compare August 5, 2026 18:24
@nnicolee
nnicolee marked this pull request as ready for review August 5, 2026 18:28
@nnicolee
nnicolee requested review from a team as code owners August 5, 2026 18:28
@sonarqubecloud

sonarqubecloud Bot commented Aug 5, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed for 'gapic-generator-java-root'

Failed conditions
B Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@sonarqubecloud

sonarqubecloud Bot commented Aug 5, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed for 'gapic-generator-java-root'

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)
B Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@nnicolee
nnicolee merged commit 50ebc70 into main Aug 6, 2026
309 of 312 checks passed
@nnicolee
nnicolee deleted the cleanup/gax-remove-javax-nonnull branch August 6, 2026 04:15
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