Skip to content

Commit 13964f2

Browse files
authored
test(bigtable): disable deep stub answers causing Java 8 Mockito reflection crash (#13831)
### 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 `BigtableDataClientTests`, Mockito's mock declarations for `ServerStreamingCallable` were configured with `answer = Answers.RETURNS_DEEP_STUBS`. When Mockito generates deep stubs, it dynamically reflects on the return type to build intermediate mocks, triggering this reflection crash on `@NullMarked` classes under Java 8 CI pipelines. ### Solution Since the tests do not actually call or rely on deep stubs for these streaming callables, we can safely remove `(answer = Answers.RETURNS_DEEP_STUBS)`. Removing deep stubs prevents Mockito from performing the reflection that causes the Java 8 pipeline crash, allowing the test suite to execute successfully.
1 parent 562a391 commit 13964f2

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

java-bigtable/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/BigtableDataClientTests.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
import org.junit.Test;
5959
import org.junit.runner.RunWith;
6060
import org.junit.runners.JUnit4;
61-
import org.mockito.Answers;
6261
import org.mockito.ArgumentMatchers;
6362
import org.mockito.Mock;
6463
import org.mockito.Mockito;
@@ -79,8 +78,7 @@ public class BigtableDataClientTests {
7978

8079
@Mock private EnhancedBigtableStub mockStub;
8180

82-
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
83-
private ServerStreamingCallable<Query, Row> mockReadRowsCallable;
81+
@Mock private ServerStreamingCallable<Query, Row> mockReadRowsCallable;
8482

8583
@Mock private UnaryCallable<Query, Row> mockReadRowCallable;
8684
@Mock private UnaryCallable<String, List<KeyOffset>> mockSampleRowKeysCallable;
@@ -96,11 +94,11 @@ public class BigtableDataClientTests {
9694
@Mock private Batcher<ByteString, Row> mockBulkReadRowsBatcher;
9795
@Mock private UnaryCallable<PrepareQueryRequest, PrepareResponse> mockPrepareQueryCallable;
9896

99-
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
97+
@Mock
10098
private ServerStreamingCallable<String, ByteStringRange>
10199
mockGenerateInitialChangeStreamPartitionsCallable;
102100

103-
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
101+
@Mock
104102
private ServerStreamingCallable<ReadChangeStreamQuery, ChangeStreamRecord>
105103
mockReadChangeStreamCallable;
106104

0 commit comments

Comments
 (0)