diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/BulkMutateIT.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/BulkMutateIT.java index bd2e8e5352..aaf32decfe 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/BulkMutateIT.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/BulkMutateIT.java @@ -210,10 +210,10 @@ public void testManyMutationsOnAuthorizedView() throws IOException, InterruptedE .bulkMutateRowsSettings() .setBatchingSettings( batchingSettings.toBuilder().setDelayThreshold(Duration.ofHours(1)).build()); - try (BigtableDataClient client = BigtableDataClient.create(settings); - Batcher batcher = - client.newBulkMutationBatcher( - AuthorizedViewId.of(testEnvRule.env().getTableId(), testAuthorizedView.getId()))) { + try (BigtableDataClient client = BigtableDataClient.create(settings)) { + Batcher batcher = + client.newBulkMutationBatcher( + AuthorizedViewId.of(testEnvRule.env().getTableId(), testAuthorizedView.getId())); String familyId = testEnvRule.env().getFamilyId(); for (int i = 0; i < 2; i++) { String key = rowPrefix + "test-key"; @@ -232,26 +232,21 @@ public void testManyMutationsOnAuthorizedView() throws IOException, InterruptedE .first() .call(Query.create(testEnvRule.env().getTableId()).rowKey(rowPrefix + "test-key")); assertThat(row.getCells()).hasSize(100002); - } - // We should not be able to mutate rows outside the authorized view - try { - try (BigtableDataClient client = BigtableDataClient.create(settings); - Batcher batcherOutsideAuthorizedView = - client.newBulkMutationBatcher( - AuthorizedViewId.of( - testEnvRule.env().getTableId().getTableId(), testAuthorizedView.getId()))) { - String keyOutsideAuthorizedView = UUID.randomUUID() + "-outside-authorized-view"; - RowMutationEntry rowMutationEntry = RowMutationEntry.create(keyOutsideAuthorizedView); - rowMutationEntry.setCell( - testEnvRule.env().getFamilyId(), AUTHORIZED_VIEW_COLUMN_QUALIFIER, "test-value"); - @SuppressWarnings("UnusedVariable") - ApiFuture ignored = batcherOutsideAuthorizedView.add(rowMutationEntry); - batcherOutsideAuthorizedView.flush(); + // We should not be able to mutate rows outside the authorized view + String keyOutsideAuthorizedView = UUID.randomUUID() + "-outside-authorized-view"; + RowMutationEntry rowMutationEntry = RowMutationEntry.create(keyOutsideAuthorizedView); + rowMutationEntry.setCell( + testEnvRule.env().getFamilyId(), AUTHORIZED_VIEW_COLUMN_QUALIFIER, "test-value"); + try { + ApiFuture ignored = batcher.add(rowMutationEntry); + batcher.flush(); + // error message is only thrown when closing the batcher + batcher.close(); + fail("Should not be able to apply bulk mutation on rows outside authorized view"); + } catch (Exception e) { + // ignore } - fail("Should not be able to apply bulk mutation on rows outside authorized view"); - } catch (Exception e) { - // Ignore. } testEnvRule