This is an automated email from the ASF dual-hosted git repository.
damondouglas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push:
new 80311628c27 Remove warning from catch in table exists validation
(#28288)
80311628c27 is described below
commit 80311628c27ea68704f46d9f5e6edea6466dfcb3
Author: Damon <[email protected]>
AuthorDate: Fri Sep 29 13:04:18 2023 -0700
Remove warning from catch in table exists validation (#28288)
* Remove warning from catch in table exists validation
* Remove warning from catch in read table exists validation
* Throw RuntimeException instead
---
.../beam/sdk/io/gcp/bigtable/BigtableIO.java | 24 ++++++++++------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git
a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableIO.java
b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableIO.java
index 9f3c627a89e..92a0af20548 100644
---
a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableIO.java
+++
b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableIO.java
@@ -19,8 +19,8 @@ package org.apache.beam.sdk.io.gcp.bigtable;
import static
org.apache.beam.sdk.io.gcp.bigtable.BigtableServiceFactory.BigtableServiceEntry;
import static org.apache.beam.sdk.options.ValueProvider.StaticValueProvider;
+import static org.apache.beam.sdk.util.Preconditions.checkArgumentNotNull;
import static
org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkArgument;
-import static
org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkNotNull;
import static
org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkState;
import com.google.auto.value.AutoValue;
@@ -689,14 +689,13 @@ public class BigtableIO {
private void validateTableExists(
BigtableConfig config, BigtableReadOptions readOptions,
PipelineOptions options) {
if (config.getValidate() && config.isDataAccessible() &&
readOptions.isDataAccessible()) {
- String tableId = checkNotNull(readOptions.getTableId().get());
+ ValueProvider<String> tableIdProvider =
checkArgumentNotNull(readOptions.getTableId());
+ String tableId = checkArgumentNotNull(tableIdProvider.get());
try {
- checkArgument(
- getServiceFactory().checkTableExists(config, options, tableId),
- "Table %s does not exist",
- tableId);
+ boolean exists = getServiceFactory().checkTableExists(config,
options, tableId);
+ checkArgument(exists, "Table %s does not exist", tableId);
} catch (IOException e) {
- LOG.warn("Error checking whether table {} exists; proceeding.",
tableId, e);
+ throw new RuntimeException(e);
}
}
}
@@ -1122,14 +1121,13 @@ public class BigtableIO {
private void validateTableExists(
BigtableConfig config, BigtableWriteOptions writeOptions,
PipelineOptions options) {
if (config.getValidate() && config.isDataAccessible() &&
writeOptions.isDataAccessible()) {
- String tableId = checkNotNull(writeOptions.getTableId().get());
+ ValueProvider<String> tableIdProvider =
checkArgumentNotNull(writeOptions.getTableId());
+ String tableId = checkArgumentNotNull(tableIdProvider.get());
try {
- checkArgument(
- factory.checkTableExists(config, options,
writeOptions.getTableId().get()),
- "Table %s does not exist",
- tableId);
+ boolean exists = factory.checkTableExists(config, options, tableId);
+ checkArgument(exists, "Table %s does not exist", tableId);
} catch (IOException e) {
- LOG.warn("Error checking whether table {} exists; proceeding.",
tableId, e);
+ throw new RuntimeException(e);
}
}
}