Skip to content

[TEST] Jspecify bigtable test#13835

Closed
lqiu96 wants to merge 31 commits into
mainfrom
jspecify-bigtable-test
Closed

[TEST] Jspecify bigtable test#13835
lqiu96 wants to merge 31 commits into
mainfrom
jspecify-bigtable-test

Conversation

@lqiu96

@lqiu96 lqiu96 commented Jul 20, 2026

Copy link
Copy Markdown
Member

No description provided.

nnicolee and others added 30 commits July 16, 2026 18:01
Disable annotations in Mockito mocks for GAX classes across 17 test
files in `google-cloud-bigtable` to avoid ArrayStoreException on Java 8.
These tests were missed in the previous round of fixes.

TAG=agy
CONV=de3ef09d-a26c-4190-b578-4c993f807bdc
Disable annotations in Mockito mocks for GAX classes across 17 test
files in `google-cloud-bigtable` to avoid ArrayStoreException on Java 8.
These tests were missed in the previous round of fixes.

TAG=agy
CONV=de3ef09d-a26c-4190-b578-4c993f807bdc
… mocks

Remove `defaultAnswer(Answers.RETURNS_DEEP_STUBS)` from programmatic
mocks of `ServerStreamingCallable` in `BigtableDataClientTests`.
Mockito's deep stubs cause reflection crashes on Java 8 when dealing
with JSpecify annotations. Since the tests do not rely on deep stubs
for these callables, they can be safely removed.

TAG=agy
CONV=de3ef09d-a26c-4190-b578-4c993f807bdc
…e-test

TAG=agy
CONV=7a3e3817-a94f-49c3-aad6-cf6d0b9873ff

@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 introduces JSpecify nullability annotations across the codebase to improve null safety and type checking. The changes involve adding @NullMarked to classes and interfaces, and using @Nullable for fields and parameters where appropriate. I have reviewed the changes and provided feedback on some minor inconsistencies in annotation placement and field nullability definitions to ensure compliance with JSpecify guidelines.

// This is initialized once for the lifetime of the application. This enables re-using
// channels to S2A.
private static volatile ChannelCredentials s2aChannelCredentials;
private static @Nullable volatile ChannelCredentials s2aChannelCredentials;

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.

medium

According to JSpecify guidelines and standard Java modifier order, type-use annotations like @Nullable should be placed immediately before the type they qualify, after any modifiers (such as private, static, volatile). Please move @Nullable after volatile.

Suggested change
private static @Nullable volatile ChannelCredentials s2aChannelCredentials;
private static volatile @Nullable ChannelCredentials s2aChannelCredentials;

Comment on lines +114 to 116
@Nullable
@GuardedBy("lock")
private HttpRequestRunnable<RequestT, ResponseT> requestRunnable;

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.

medium

According to JSpecify guidelines, type-use annotations like @Nullable should be placed immediately before the type they qualify, after any modifiers (such as private, final, volatile) and declaration annotations (such as @GuardedBy). Please move @Nullable after private.

Suggested change
@Nullable
@GuardedBy("lock")
private HttpRequestRunnable<RequestT, ResponseT> requestRunnable;
@GuardedBy("lock")
private @Nullable HttpRequestRunnable<RequestT, ResponseT> requestRunnable;

Comment on lines +131 to 133
@Nullable
@GuardedBy("lock")
private volatile ScheduledFuture<?> timeoutFuture;

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.

medium

According to JSpecify guidelines, type-use annotations like @Nullable should be placed immediately before the type they qualify, after any modifiers (such as private, volatile) and declaration annotations (such as @GuardedBy). Please move @Nullable after volatile.

Suggested change
@Nullable
@GuardedBy("lock")
private volatile ScheduledFuture<?> timeoutFuture;
@GuardedBy("lock")
private volatile @Nullable ScheduledFuture<?> timeoutFuture;


private GrpcCallContext(
Channel channel,
@Nullable Channel channel,

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.

medium

The constructor parameter channel is marked @Nullable, but the corresponding field channel (at line 89) is not marked @Nullable. Since the class is @NullMarked, any unannotated type is considered non-null, which creates a mismatch. Please ensure the channel field is also marked @Nullable if it can be null. The same applies to the endpointContext field.


private HttpJsonCallContext(
HttpJsonChannel channel,
@Nullable HttpJsonChannel channel,

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.

medium

The constructor parameter channel is marked @Nullable, but the corresponding field channel (at line 72) is not marked @Nullable. Since the class is @NullMarked, any unannotated type is considered non-null, which creates a mismatch. Please ensure the channel field is also marked @Nullable if it can be null. The same applies to the tracer and endpointContext fields.

@sonarqubecloud

Copy link
Copy Markdown

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

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

See analysis details on SonarQube Cloud

💡 Need a hand with PR review? Try Gitar by Sonar!

@sonarqubecloud

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 Maintainability Rating on New Code (required ≥ A)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

💡 Need a hand with PR review? Try Gitar by Sonar!

@lqiu96 lqiu96 closed this Jul 20, 2026
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