Skip to content

Commit 984b5bb

Browse files
committed
Lists.transform is lazy therefore retrying will always occur regardless if insertIds are set
1 parent 170f1e5 commit 984b5bb

File tree

1 file changed

+10
-8
lines changed
  • google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery

1 file changed

+10
-8
lines changed

google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@
4040
import com.google.common.annotations.VisibleForTesting;
4141
import com.google.common.base.Function;
4242
import com.google.common.base.Supplier;
43+
import com.google.common.collect.FluentIterable;
4344
import com.google.common.collect.ImmutableList;
4445
import com.google.common.collect.Iterables;
45-
import com.google.common.collect.Lists;
4646
import com.google.common.collect.Maps;
4747
import java.util.List;
4848
import java.util.Map;
@@ -468,13 +468,15 @@ public InsertAllResponse insertAll(InsertAllRequest request) {
468468
// Using an array of size 1 here to have a mutable boolean variable, which can be modified in
469469
// an anonymous inner class.
470470
final boolean[] allInsertIdsSet = {true};
471-
List<Rows> rowsPb = Lists.transform(request.getRows(), new Function<RowToInsert, Rows>() {
472-
@Override
473-
public Rows apply(RowToInsert rowToInsert) {
474-
allInsertIdsSet[0] &= rowToInsert.getId() != null;
475-
return new Rows().setInsertId(rowToInsert.getId()).setJson(rowToInsert.getContent());
476-
}
477-
});
471+
List<Rows> rowsPb = FluentIterable.from(request.getRows())
472+
.transform(new Function<RowToInsert, Rows>() {
473+
@Override
474+
public Rows apply(RowToInsert rowToInsert) {
475+
allInsertIdsSet[0] &= rowToInsert.getId() != null;
476+
return new Rows().setInsertId(rowToInsert.getId()).setJson(rowToInsert.getContent());
477+
}
478+
})
479+
.toList();
478480
requestPb.setRows(rowsPb);
479481

480482
TableDataInsertAllResponse responsePb;

0 commit comments

Comments
 (0)