Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

Commit fd863ae

Browse files
committed
PR feedback
1 parent bb2a0a9 commit fd863ae

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,17 @@ public static ConsistencyRequest forDataBoost(String tableId) {
7474

7575
@InternalApi
7676
public static ConsistencyRequest forReplicationFromTableName(String tableName) {
77+
Preconditions.checkArgument(
78+
TableName.isParsableFrom(tableName), "tableName must be a fully qualified table name");
7779
return new AutoValue_ConsistencyRequest(
7880
tableName, CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES, null, true);
7981
}
8082

8183
@InternalApi
8284
public static ConsistencyRequest forReplicationFromTableName(
8385
String tableName, String consistencyToken) {
86+
Preconditions.checkArgument(
87+
TableName.isParsableFrom(tableName), "tableName must be a fully qualified table name");
8488
Preconditions.checkNotNull(consistencyToken, "consistencyToken must not be null");
8589

8690
return new AutoValue_ConsistencyRequest(

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/stub/EnhancedBigtableTableAdminStub.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ public static EnhancedBigtableTableAdminStub createEnhanced(
7676
return new EnhancedBigtableTableAdminStub(settings, ClientContext.create(settings), null);
7777
}
7878

79+
/**
80+
* Creates an instance of {@link EnhancedBigtableTableAdminStub} using the provided settings.
81+
* This variant is used by the legacy client stack which relies on short table IDs and
82+
* requires a {@link TableAdminRequestContext} to construct fully qualified table names.
83+
*
84+
* @param settings The settings used to configure the stub.
85+
* @param requestContext The context used to format short table IDs.
86+
* @return A new instance of {@code EnhancedBigtableTableAdminStub}.
87+
* @throws IOException If there are errors creating the underlying client context.
88+
*/
7989
public static EnhancedBigtableTableAdminStub createEnhanced(
8090
BigtableTableAdminStubSettings settings, TableAdminRequestContext requestContext)
8191
throws IOException {

google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/ConsistencyRequestTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,14 @@ public void testToGenerateTokenProtoFromTableName() {
138138

139139
assertThat(generateRequest.getName()).isEqualTo(fullTableName);
140140
}
141+
142+
@Test(expected = IllegalArgumentException.class)
143+
public void testForReplicationFromTableNameInvalid() {
144+
ConsistencyRequest.forReplicationFromTableName(TABLE_ID);
145+
}
146+
147+
@Test(expected = IllegalArgumentException.class)
148+
public void testForReplicationFromTableNameWithTokenInvalid() {
149+
ConsistencyRequest.forReplicationFromTableName(TABLE_ID, CONSISTENCY_TOKEN);
150+
}
141151
}

0 commit comments

Comments
 (0)