Skip to content

Commit c3fc40d

Browse files
authored
deps: upgrade gax to 1.53.0 (#145)
* deps: upgrade gax to 1.53.0 * fix compile failures * rename parameter * rename test variables * review feedback * review feedback
1 parent 2ea6704 commit c3fc40d

File tree

3 files changed

+50
-29
lines changed

3 files changed

+50
-29
lines changed

google-cloud-bigtable-deps-bom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<properties>
7474
<autovalue.version>1.7</autovalue.version>
7575
<!-- when updating, make sure to align the versions of transitive deps below -->
76-
<gax.version>1.52.0</gax.version>
76+
<gax.version>1.53.0</gax.version>
7777
<google.api-common.version>1.8.1</google.api-common.version>
7878
<google.common-protos.version>1.17.0</google.common-protos.version>
7979
<google.core.version>1.92.1</google.core.version>

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptor.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package com.google.cloud.bigtable.data.v2.stub.mutaterows;
1717

1818
import com.google.api.core.InternalApi;
19-
import com.google.api.core.SettableApiFuture;
19+
import com.google.api.gax.batching.BatchEntry;
2020
import com.google.api.gax.batching.BatchingDescriptor;
2121
import com.google.api.gax.batching.BatchingRequestBuilder;
2222
import com.google.cloud.bigtable.data.v2.models.BulkMutation;
@@ -45,9 +45,9 @@ public BatchingRequestBuilder<RowMutationEntry, BulkMutation> newRequestBuilder(
4545
}
4646

4747
@Override
48-
public void splitResponse(Void response, List<SettableApiFuture<Void>> batch) {
49-
for (SettableApiFuture<Void> batchResponse : batch) {
50-
batchResponse.set(null);
48+
public void splitResponse(Void response, List<BatchEntry<RowMutationEntry, Void>> entries) {
49+
for (BatchEntry<RowMutationEntry, Void> batchResponse : entries) {
50+
batchResponse.getResultFuture().set(null);
5151
}
5252
}
5353

@@ -58,10 +58,11 @@ public void splitResponse(Void response, List<SettableApiFuture<Void>> batch) {
5858
* entries whose index is mentioned {@link MutateRowsException#getFailedMutations()}.
5959
*/
6060
@Override
61-
public void splitException(Throwable throwable, List<SettableApiFuture<Void>> batch) {
61+
public void splitException(
62+
Throwable throwable, List<BatchEntry<RowMutationEntry, Void>> entries) {
6263
if (!(throwable instanceof MutateRowsException)) {
63-
for (SettableApiFuture<Void> future : batch) {
64-
future.setException(throwable);
64+
for (BatchEntry<RowMutationEntry, Void> entry : entries) {
65+
entry.getResultFuture().setException(throwable);
6566
}
6667
return;
6768
}
@@ -74,12 +75,12 @@ public void splitException(Throwable throwable, List<SettableApiFuture<Void>> ba
7475
}
7576

7677
int i = 0;
77-
for (SettableApiFuture<Void> entryResultFuture : batch) {
78+
for (BatchEntry<RowMutationEntry, Void> entry : entries) {
7879
Throwable entryError = entryErrors.get(i++);
7980
if (entryError == null) {
80-
entryResultFuture.set(null);
81+
entry.getResultFuture().set(null);
8182
} else {
82-
entryResultFuture.setException(entryError);
83+
entry.getResultFuture().setException(entryError);
8384
}
8485
}
8586
}

google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptorTest.java

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static com.google.common.truth.Truth.assertThat;
1919

2020
import com.google.api.core.SettableApiFuture;
21+
import com.google.api.gax.batching.BatchEntry;
2122
import com.google.api.gax.batching.BatchingRequestBuilder;
2223
import com.google.api.gax.grpc.GrpcStatusCode;
2324
import com.google.api.gax.rpc.DeadlineExceededException;
@@ -77,29 +78,43 @@ public void requestBuilderTest() {
7778

7879
@Test
7980
public void splitResponseTest() {
80-
List<SettableApiFuture<Void>> batchResponse =
81-
ImmutableList.of(SettableApiFuture.<Void>create(), SettableApiFuture.<Void>create());
82-
assertThat(batchResponse.get(0).isDone()).isFalse();
83-
assertThat(batchResponse.get(1).isDone()).isFalse();
81+
BatchEntry<RowMutationEntry, Void> batchEntry1 =
82+
BatchEntry.create(
83+
RowMutationEntry.create("key1").deleteRow(), SettableApiFuture.<Void>create());
84+
BatchEntry<RowMutationEntry, Void> batchEntry2 =
85+
BatchEntry.create(
86+
RowMutationEntry.create("key2").deleteRow(), SettableApiFuture.<Void>create());
87+
88+
List<BatchEntry<RowMutationEntry, Void>> batchResponse =
89+
ImmutableList.of(batchEntry1, batchEntry2);
90+
assertThat(batchResponse.get(0).getResultFuture().isDone()).isFalse();
91+
assertThat(batchResponse.get(1).getResultFuture().isDone()).isFalse();
8492

8593
MutateRowsBatchingDescriptor underTest = new MutateRowsBatchingDescriptor();
8694
underTest.splitResponse(null, batchResponse);
87-
assertThat(batchResponse.get(0).isDone()).isTrue();
88-
assertThat(batchResponse.get(1).isDone()).isTrue();
95+
assertThat(batchResponse.get(0).getResultFuture().isDone()).isTrue();
96+
assertThat(batchResponse.get(1).getResultFuture().isDone()).isTrue();
8997
}
9098

9199
@Test
92100
public void splitExceptionTest() {
101+
BatchEntry<RowMutationEntry, Void> batchEntry1 =
102+
BatchEntry.create(
103+
RowMutationEntry.create("key1").deleteRow(), SettableApiFuture.<Void>create());
104+
BatchEntry<RowMutationEntry, Void> batchEntry2 =
105+
BatchEntry.create(
106+
RowMutationEntry.create("key2").deleteRow(), SettableApiFuture.<Void>create());
107+
93108
MutateRowsBatchingDescriptor underTest = new MutateRowsBatchingDescriptor();
94109
final RuntimeException expectedEx = new RuntimeException("Caused while batching");
95-
List<SettableApiFuture<Void>> batchResponses =
96-
ImmutableList.of(SettableApiFuture.<Void>create(), SettableApiFuture.<Void>create());
110+
List<BatchEntry<RowMutationEntry, Void>> batchResponses =
111+
ImmutableList.of(batchEntry1, batchEntry2);
97112

98113
underTest.splitException(expectedEx, batchResponses);
99114

100-
for (SettableApiFuture fu : batchResponses) {
115+
for (BatchEntry<RowMutationEntry, Void> response : batchResponses) {
101116
try {
102-
fu.get();
117+
response.getResultFuture().get();
103118
} catch (ExecutionException | InterruptedException ex) {
104119
assertThat(ex).hasCauseThat().isSameInstanceAs(expectedEx);
105120
}
@@ -110,9 +125,15 @@ public void splitExceptionTest() {
110125
public void splitExceptionWithFailedMutationsTest() {
111126
MutateRowsBatchingDescriptor underTest = new MutateRowsBatchingDescriptor();
112127
Throwable actualThrowable = null;
113-
SettableApiFuture<Void> resultFuture1 = SettableApiFuture.create();
114-
SettableApiFuture<Void> resultFuture2 = SettableApiFuture.create();
115-
SettableApiFuture<Void> resultFuture3 = SettableApiFuture.create();
128+
BatchEntry<RowMutationEntry, Void> batchEntry1 =
129+
BatchEntry.create(
130+
RowMutationEntry.create("key1").deleteRow(), SettableApiFuture.<Void>create());
131+
BatchEntry<RowMutationEntry, Void> batchEntry2 =
132+
BatchEntry.create(
133+
RowMutationEntry.create("key2").deleteRow(), SettableApiFuture.<Void>create());
134+
BatchEntry<RowMutationEntry, Void> batchEntry3 =
135+
BatchEntry.create(
136+
RowMutationEntry.create("key3").deleteRow(), SettableApiFuture.<Void>create());
116137

117138
// Threw an exception at 1st and 3rd entry
118139
MutateRowsException serverError =
@@ -128,11 +149,10 @@ public void splitExceptionWithFailedMutationsTest() {
128149
new DeadlineExceededException(
129150
null, GrpcStatusCode.of(Status.Code.DEADLINE_EXCEEDED), true))),
130151
true);
131-
underTest.splitException(
132-
serverError, ImmutableList.of(resultFuture1, resultFuture2, resultFuture3));
152+
underTest.splitException(serverError, ImmutableList.of(batchEntry1, batchEntry2, batchEntry3));
133153

134154
try {
135-
resultFuture1.get();
155+
batchEntry1.getResultFuture().get();
136156
} catch (ExecutionException | InterruptedException e) {
137157
actualThrowable = e;
138158
}
@@ -143,15 +163,15 @@ public void splitExceptionWithFailedMutationsTest() {
143163
// As there is no exception for 2nd entry so it should not throw any exception
144164
actualThrowable = null;
145165
try {
146-
resultFuture2.get();
166+
batchEntry2.getResultFuture().get();
147167
} catch (ExecutionException | InterruptedException e) {
148168
actualThrowable = e;
149169
}
150170
assertThat(actualThrowable).isNull();
151171

152172
actualThrowable = null;
153173
try {
154-
resultFuture3.get();
174+
batchEntry3.getResultFuture().get();
155175
} catch (ExecutionException | InterruptedException e) {
156176
actualThrowable = e;
157177
}

0 commit comments

Comments
 (0)