Skip to content

test(pubsub): fix JSpecify compatibility issues on Java 8 for Mockito tests#13808

Merged
lqiu96 merged 2 commits into
mainfrom
fix-jspecify-ci-pubsub-mockito
Jul 17, 2026
Merged

test(pubsub): fix JSpecify compatibility issues on Java 8 for Mockito tests#13808
lqiu96 merged 2 commits into
mainfrom
fix-jspecify-ci-pubsub-mockito

Conversation

@lqiu96

@lqiu96 lqiu96 commented Jul 17, 2026

Copy link
Copy Markdown
Member

Update Mockito mocks in pubsub tests to use withSettings().withoutAnnotations() to avoid ArrayStoreException on Java 8 due to JSpecify's @NullMarked annotation. Explicitly mock callables instead of relying on RETURNS_DEEP_STUBS which does not propagate the settings.

@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 refactors the unit tests in MessageDispatcherTest and StreamingSubscriberConnectionTest. Specifically, it updates mock creation to consistently use withSettings().withoutAnnotations() and refactors StreamingSubscriberConnectionTest to use class-level mock callables (mockStreamingCallable, mockAcknowledgeCallable, and mockModifyAckDeadlineCallable) instead of relying on deep stubbing of SubscriberStub. This simplifies the test setup and reduces redundant mock creation in individual test cases. There are no review comments to address.

lqiu96 added 2 commits July 17, 2026 20:00
… tests

Update Mockito mocks in pubsub tests to use `withSettings().withoutAnnotations()`
to avoid `ArrayStoreException` on Java 8 due to JSpecify's `@NullMarked` annotation.
Explicitly mock callables instead of relying on `RETURNS_DEEP_STUBS` which does
not propagate the settings.

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

Stub mock callables to return pending SettableApiFuture and default ClientStream
to avoid NullPointerException during connection startup and operation in tests.

TAG=agy
CONV=de3ef09d-a26c-4190-b578-4c993f807bdc
@lqiu96
lqiu96 force-pushed the fix-jspecify-ci-pubsub-mockito branch from b675143 to dbd89d6 Compare July 17, 2026 20:00
@lqiu96
lqiu96 requested a review from michaelpri10 July 17, 2026 20:05
@lqiu96
lqiu96 marked this pull request as ready for review July 17, 2026 20:05
@lqiu96
lqiu96 requested review from a team as code owners July 17, 2026 20:05
@lqiu96
lqiu96 enabled auto-merge (squash) July 17, 2026 20:13
@lqiu96
lqiu96 merged commit eb608db into main Jul 17, 2026
212 of 213 checks passed
@lqiu96
lqiu96 deleted the fix-jspecify-ci-pubsub-mockito branch July 17, 2026 20:23
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