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 9f3c627a89ef..92a0af205482 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 @@ 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 final String toString() { private void validateTableExists( BigtableConfig config, BigtableReadOptions readOptions, PipelineOptions options) { if (config.getValidate() && config.isDataAccessible() && readOptions.isDataAccessible()) { - String tableId = checkNotNull(readOptions.getTableId().get()); + ValueProvider 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 String toString() { private void validateTableExists( BigtableConfig config, BigtableWriteOptions writeOptions, PipelineOptions options) { if (config.getValidate() && config.isDataAccessible() && writeOptions.isDataAccessible()) { - String tableId = checkNotNull(writeOptions.getTableId().get()); + ValueProvider 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); } } }