Skip to content

Commit 562a391

Browse files
authored
test(storage): fix JSpecify CI issues on Java 8 (#13810)
Disable annotations in Mockito mocks for Gax callables and contexts to avoid ArrayStoreException on Java 8 when reflecting on JSpecify annotations.
1 parent ac98dfe commit 562a391

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

java-storage/google-cloud-storage/src/test/java/com/google/cloud/storage/GapicUploadSessionBuilderSyntaxTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@
3030
import com.google.storage.v2.WriteObjectResponse;
3131
import org.junit.Before;
3232
import org.junit.Test;
33-
import org.junit.runner.RunWith;
34-
import org.mockito.Mock;
35-
import org.mockito.junit.MockitoJUnitRunner;
33+
import org.mockito.Mockito;
3634

3735
/**
3836
* For our {@link GapicUploadSessionBuilder} a number of items must be provided to ultimately
@@ -43,7 +41,6 @@
4341
* the builders. Each builder is built which runs some minor validation - such as null checks - but
4442
* otherwise does not have any other logic.
4543
*/
46-
@RunWith(MockitoJUnitRunner.class)
4744
public final class GapicUploadSessionBuilderSyntaxTest {
4845

4946
private final WriteObjectRequest req = WriteObjectRequest.getDefaultInstance();
@@ -52,14 +49,17 @@ public final class GapicUploadSessionBuilderSyntaxTest {
5249
// We need them to be non-null, but otherwise they do not matter.
5350
// They have many dependencies which would need to be constructed in order to instantiate a
5451
// literal instance.
55-
@Mock private ClientStreamingCallable<WriteObjectRequest, WriteObjectResponse> write;
52+
private ClientStreamingCallable<WriteObjectRequest, WriteObjectResponse> write;
5653

57-
@Mock
5854
private UnaryCallable<StartResumableWriteRequest, StartResumableWriteResponse>
5955
startResumableWrite;
6056

6157
@Before
6258
public void setUp() throws Exception {
59+
write =
60+
Mockito.mock(ClientStreamingCallable.class, Mockito.withSettings().withoutAnnotations());
61+
startResumableWrite =
62+
Mockito.mock(UnaryCallable.class, Mockito.withSettings().withoutAnnotations());
6363
when(startResumableWrite.call(any()))
6464
.thenReturn(StartResumableWriteResponse.getDefaultInstance());
6565
}

java-storage/google-cloud-storage/src/test/java/com/google/cloud/storage/GrpcTransformPageDecoratorTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
public class GrpcTransformPageDecoratorTest {
4444

4545
// define some common data used across our tests
46-
private final ApiCallContext apiCallContext = Mockito.mock(ApiCallContext.class);
46+
private final ApiCallContext apiCallContext =
47+
Mockito.mock(ApiCallContext.class, Mockito.withSettings().withoutAnnotations());
4748

4849
// Initial values for the first page
4950
private final ImmutableList<String> page1 = ImmutableList.of("string1", "string2", "string3");

0 commit comments

Comments
 (0)