Commit dbc9b14
test(spanner): disable Mockito annotation copying for Credentials, ServiceAccountCredentials, and RequestMetadataCallback (googleapis#13861)
### 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.1 parent c21d74d commit dbc9b14
2 files changed
Lines changed: 15 additions & 7 deletions
File tree
- java-spanner/google-cloud-spanner/src/test/java/com/google/cloud/spanner
- connection
Lines changed: 13 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
52 | 57 | | |
53 | 58 | | |
54 | 59 | | |
| |||
70 | 75 | | |
71 | 76 | | |
72 | 77 | | |
73 | | - | |
| 78 | + | |
| 79 | + | |
74 | 80 | | |
75 | 81 | | |
76 | 82 | | |
| |||
111 | 117 | | |
112 | 118 | | |
113 | 119 | | |
114 | | - | |
| 120 | + | |
| 121 | + | |
115 | 122 | | |
116 | 123 | | |
117 | 124 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
477 | 478 | | |
478 | 479 | | |
479 | 480 | | |
480 | | - | |
| 481 | + | |
481 | 482 | | |
482 | 483 | | |
483 | 484 | | |
| |||
0 commit comments