Commit 62c22b7
authored
test(spanner): disable annotation copying on ServerStream mocks causing Java 8 crash (#13832)
### 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 `PartitionedDmlTransactionTest`, two mock declarations for
`ServerStream` were created using the default `mock(ServerStream.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 `mock(ServerStream.class)` with `mock(ServerStream.class,
withSettings().withoutAnnotations())` in
`testExecuteStreamingPartitionedUpdateRSTstream` and
`testExecuteStreamingPartitionedUpdateGenericInternalException` to match
the other passing tests. This disables annotation copying on the mocked
`ServerStream` instances and bypasses the Java 8 reflection limitations.1 parent 3700cf4 commit 62c22b7
1 file changed
Lines changed: 6 additions & 3 deletions
File tree
- java-spanner/google-cloud-spanner/src/test/java/com/google/cloud/spanner
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
373 | | - | |
| 373 | + | |
| 374 | + | |
374 | 375 | | |
375 | 376 | | |
376 | 377 | | |
| |||
382 | 383 | | |
383 | 384 | | |
384 | 385 | | |
385 | | - | |
| 386 | + | |
| 387 | + | |
386 | 388 | | |
387 | 389 | | |
388 | 390 | | |
| |||
407 | 409 | | |
408 | 410 | | |
409 | 411 | | |
410 | | - | |
| 412 | + | |
| 413 | + | |
411 | 414 | | |
412 | 415 | | |
413 | 416 | | |
| |||
0 commit comments