Skip to content

test(spanner): disable Mockito annotation copying for Credentials, ServiceAccountCredentials, and RequestMetadataCallback#13861

Merged
nnicolee merged 2 commits into
mainfrom
test/spanner-disable-annotations
Jul 22, 2026
Merged

test(spanner): disable Mockito annotation copying for Credentials, ServiceAccountCredentials, and RequestMetadataCallback#13861
nnicolee merged 2 commits into
mainfrom
test/spanner-disable-annotations

Conversation

@nnicolee

@nnicolee nnicolee commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Problem

In JSpecify 1.0.0, the @NullMarked annotation targets ElementType.MODULE. Because ElementType.MODULE was introduced in Java 9, reflecting on @NullMarked classes under Java 8 (JDK 1.8) throws EnumConstantNotPresentExceptionProxy wrapped in an ArrayStoreException.

In MutableCredentialsTest and SpannerPoolTest, mock declarations for Credentials, ServiceAccountCredentials, and RequestMetadataCallback were created using the default mock(Class.class) without setting .withoutAnnotations(). Mockito attempts to copy annotations on the mock subclasses, triggering the reflection crash on the JSpecify @NullMarked annotation during Java 8 CI pipelines.

Solution

Replaced default mock(...) calls with mock(..., withSettings().withoutAnnotations()) for:

  • Credentials in SpannerPoolTest
  • ServiceAccountCredentials and RequestMetadataCallback in MutableCredentialsTest

This disables annotation copying on these mocked instances and bypasses the Java 8 reflection limitations.

@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 updates mock creation in MutableCredentialsTest and SpannerPoolTest to use Mockito's withSettings().withoutAnnotations() when mocking credentials classes. There are no review comments, and I have no feedback to provide.

@nnicolee nnicolee added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 22, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 22, 2026
@nnicolee nnicolee changed the title test(spanner): disable Mockito annotation copying for Credentials and ServiceAccountCredentials test(spanner): disable Mockito annotation copying for Credentials, ServiceAccountCredentials, and RequestMetadataCallback Jul 22, 2026
@nnicolee
nnicolee marked this pull request as ready for review July 22, 2026 15:33
@nnicolee
nnicolee requested review from a team as code owners July 22, 2026 15:33
@nnicolee
nnicolee merged commit 56678e6 into main Jul 22, 2026
210 checks passed
@nnicolee
nnicolee deleted the test/spanner-disable-annotations branch July 22, 2026 17:36
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.

3 participants