Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions google-cloud-jar-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions java-bigquerystorage/google-cloud-bigquerystorage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@
<artifactId>opentelemetry-sdk-trace</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand All @@ -26,6 +27,7 @@
import static org.junit.jupiter.api.Assertions.fail;

import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.api.gax.rpc.NotFoundException;
import com.google.api.gax.rpc.ServerStream;
import com.google.api.gax.rpc.UnauthenticatedException;
import com.google.auth.oauth2.ServiceAccountCredentials;
Expand Down Expand Up @@ -79,6 +81,7 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
Expand Down Expand Up @@ -1230,7 +1233,14 @@ private void ProcessRowsAtSnapshot(
TableReadOptions.newBuilder().setRowRestriction(filter).build());
}

ReadSession session = client.createReadSession(createSessionRequestBuilder.build());
final CreateReadSessionRequest request = createSessionRequestBuilder.build();
ReadSession session =
await()
.atMost(Duration.ofSeconds(10))
.pollInterval(Duration.ofSeconds(1))
// retry if the newly-created table has not yet fully propagated
.ignoreException(NotFoundException.class)
.until(() -> client.createReadSession(request), Objects::nonNull);
Comment on lines +1237 to +1243

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

To prevent potential compilation errors due to class name conflicts (e.g., with com.google.protobuf.Duration or org.threeten.bp.Duration which are commonly imported in client library tests), it is safer to use the fully qualified java.time.Duration class name.

Suggested change
ReadSession session =
await()
.atMost(Duration.ofSeconds(30))
.pollInterval(Duration.ofSeconds(1))
.ignoreException(NotFoundException.class)
.until(() -> client.createReadSession(request), Objects::nonNull);
ReadSession session =
await()
.atMost(java.time.Duration.ofSeconds(30))
.pollInterval(java.time.Duration.ofSeconds(1))
.ignoreException(NotFoundException.class)
.until(() -> client.createReadSession(request), Objects::nonNull);

assertEquals(
1,
session.getStreamsCount(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand All @@ -26,6 +27,7 @@
import static org.junit.jupiter.api.Assertions.fail;

import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.api.gax.rpc.NotFoundException;
import com.google.api.gax.rpc.ServerStream;
import com.google.api.gax.rpc.UnauthenticatedException;
import com.google.auth.oauth2.ServiceAccountCredentials;
Expand Down Expand Up @@ -76,6 +78,7 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import java.util.logging.Logger;
import org.apache.avro.Conversions;
Expand Down Expand Up @@ -1211,7 +1214,14 @@ private void ProcessRowsAtSnapshot(
.setReadOptions(TableReadOptions.newBuilder().setRowRestriction(filter).build());
}

ReadSession session = client.createReadSession(createSessionRequestBuilder.build());
final CreateReadSessionRequest request = createSessionRequestBuilder.build();
ReadSession session =
await()
.atMost(Duration.ofSeconds(10))
.pollInterval(Duration.ofSeconds(1))
// retry if the newly-created table has not yet fully propagated
.ignoreException(NotFoundException.class)
.until(() -> client.createReadSession(request), Objects::nonNull);
Comment on lines +1218 to +1224

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

To prevent potential compilation errors due to class name conflicts (e.g., with com.google.protobuf.Duration or org.threeten.bp.Duration which are commonly imported in client library tests), it is safer to use the fully qualified java.time.Duration class name.

Suggested change
ReadSession session =
await()
.atMost(Duration.ofSeconds(30))
.pollInterval(Duration.ofSeconds(1))
.ignoreException(NotFoundException.class)
.until(() -> client.createReadSession(request), Objects::nonNull);
ReadSession session =
await()
.atMost(java.time.Duration.ofSeconds(30))
.pollInterval(java.time.Duration.ofSeconds(1))
.ignoreException(NotFoundException.class)
.until(() -> client.createReadSession(request), Objects::nonNull);

assertEquals(
1,
session.getStreamsCount(),
Expand Down
Loading