Skip to content
Merged
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
44 changes: 44 additions & 0 deletions google-cloud-bigtable/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,50 @@
</plugins>
</build>
</profile>
<profile>
<id>error-prone</id>
<activation>
<!-- errorprone requires >= jdk17 -->
<jdk>[17,)</jdk>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<fork>true</fork>

<compilerArgs>
<arg>-XDcompilePolicy=simple</arg>
<arg>--should-stop=ifError=FLOW</arg>
<arg>-Xplugin:ErrorProne -XepExcludedPaths:.*/generated-sources/.*</arg>

<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
</compilerArgs>
<annotationProcessorPaths combine.children="append">
<path>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>${error-prone.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
<profile>
<id>enable-verbose-grpc-logs</id>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,6 @@ void checkToString(BigtableInstanceAdminSettings settings) {
for (String subSettings : SETTINGS_LIST) {
assertThat(toString).contains(subSettings + "=");
}
assertThat(toString.contains(settings.getStubSettings().toString()));
assertThat(toString).contains(settings.getStubSettings().toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static void validatePlatform() throws IOException {
Sets.difference(
ImmutableSet.of(
testEnvRule.env().getPrimaryZone(), testEnvRule.env().getSecondaryZone()),
ImmutableSet.of(zones))
ImmutableSet.copyOf(zones))
.iterator()
.next();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.google.bigtable.admin.v2.CheckConsistencyRequest;
import com.google.bigtable.admin.v2.GenerateConsistencyTokenRequest;
import com.google.cloud.bigtable.data.v2.internal.NameUtil;
import com.google.cloud.bigtable.data.v2.internal.TableAdminRequestContext;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -41,12 +42,11 @@ public void testToCheckConsistencyProtoWithStandard() {
CheckConsistencyRequest checkConsistencyRequest =
consistencyRequest.toCheckConsistencyProto(requestContext, CONSISTENCY_TOKEN);

assertThat(checkConsistencyRequest.getName().equals(TABLE_ID));
assertThat(checkConsistencyRequest.getConsistencyToken().equals(CONSISTENCY_TOKEN));
assertThat(
checkConsistencyRequest
.getModeCase()
.equals(CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES));
assertThat(checkConsistencyRequest.getName())
.isEqualTo(NameUtil.formatTableName(PROJECT_ID, INSTANCE_ID, TABLE_ID));
assertThat(checkConsistencyRequest.getConsistencyToken()).isEqualTo(CONSISTENCY_TOKEN);
assertThat(checkConsistencyRequest.getModeCase())
.isEqualTo(CheckConsistencyRequest.ModeCase.STANDARD_READ_REMOTE_WRITES);
}

@Test
Expand All @@ -59,12 +59,11 @@ public void testToCheckConsistencyProtoWithDataBoost() {
CheckConsistencyRequest checkConsistencyRequest =
consistencyRequest.toCheckConsistencyProto(requestContext, CONSISTENCY_TOKEN);

assertThat(checkConsistencyRequest.getName().equals(TABLE_ID));
assertThat(checkConsistencyRequest.getConsistencyToken().equals(CONSISTENCY_TOKEN));
assertThat(
checkConsistencyRequest
.getModeCase()
.equals(CheckConsistencyRequest.ModeCase.DATA_BOOST_READ_LOCAL_WRITES));
assertThat(checkConsistencyRequest.getName())
.isEqualTo(NameUtil.formatTableName(PROJECT_ID, INSTANCE_ID, TABLE_ID));
assertThat(checkConsistencyRequest.getConsistencyToken()).isEqualTo(CONSISTENCY_TOKEN);
assertThat(checkConsistencyRequest.getModeCase())
.isEqualTo(CheckConsistencyRequest.ModeCase.DATA_BOOST_READ_LOCAL_WRITES);
}

@Test
Expand All @@ -77,6 +76,7 @@ public void testToGenerateTokenProto() {
GenerateConsistencyTokenRequest generateRequest =
consistencyRequest.toGenerateTokenProto(requestContext);

assertThat(generateRequest.getName().equals(TABLE_ID));
assertThat(generateRequest.getName())
.isEqualTo(NameUtil.formatTableName(PROJECT_ID, INSTANCE_ID, TABLE_ID));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public void durationTimeUnitNegative() {
public void versions() {
VersionRule actual = GCRULES.maxVersions(10);
GcRule expected = buildVersionsRule(10);
assertNotNull(actual.getMaxVersions());
assertThat(actual.toProto()).isEqualTo(expected);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;

@SuppressWarnings("DoubleBraceInitialization")
@RunWith(Enclosed.class)
public class AbstractProtoStructReaderTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@SuppressWarnings("DoubleBraceInitialization")
@RunWith(JUnit4.class)
public class ProtoStructTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ private static ResultSet resultSetWithFakeStream(
return ResultSetImpl.create(SqlServerStreamImpl.create(future, stream.call(fakeCallContext)));
}

@SuppressWarnings("DoubleBraceInitialization")
@Test
public void testSingleRow() throws ExecutionException, InterruptedException {
com.google.bigtable.v2.ResultSetMetadata protoMetadata =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public void withHistoryQuery() {
}
}

@SuppressWarnings("DoubleBraceInitialization")
@Test
public void allTypes() {
PreparedStatement preparedStatement =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ public void testSuccess() throws Exception {
public void testFailure() {
Query query = Query.create("non-exist-table");
try {
Lists.newArrayList(client.readRows(query));
} catch (NotFoundException e) {
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
ArrayList<Row> ignored = Lists.newArrayList(client.readRows(query));
} catch (NotFoundException ignored) {
}

Collection<MetricData> allMetricData = metricReader.collectAllMetrics();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@
import com.google.cloud.bigtable.data.v2.models.ConditionalRowMutation;
import com.google.cloud.bigtable.data.v2.models.Mutation;
import com.google.cloud.bigtable.data.v2.models.Query;
import com.google.cloud.bigtable.data.v2.models.Range;
import com.google.cloud.bigtable.data.v2.models.ReadChangeStreamQuery;
import com.google.cloud.bigtable.data.v2.models.ReadModifyWriteRow;
import com.google.cloud.bigtable.data.v2.models.Row;
import com.google.cloud.bigtable.data.v2.models.RowMutation;
import com.google.cloud.bigtable.data.v2.models.RowMutationEntry;
import com.google.common.collect.Lists;
import io.grpc.ForwardingServerCall;
import io.grpc.Metadata;
import io.grpc.MethodDescriptor;
Expand Down Expand Up @@ -185,7 +188,8 @@ public void tearDown() throws Exception {

@Test
public void testReadRows() {
client.readRows(Query.create("fake-table")).iterator().hasNext();
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
ArrayList<Row> ignored = Lists.newArrayList(client.readRows(Query.create("fake-table")));

assertThat(fakeService.count.get()).isGreaterThan(1);
assertThat(serverMetadata).hasSize(fakeService.count.get());
Expand Down Expand Up @@ -321,7 +325,9 @@ public void testReadChangeStream() {

@Test
public void testGenerateInitialChangeStreamPartition() {
client.generateInitialChangeStreamPartitions("table").iterator().hasNext();
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
ArrayList<Range.ByteStringRange> ignored =
Lists.newArrayList(client.generateInitialChangeStreamPartitions("table"));

assertThat(fakeService.count.get()).isGreaterThan(1);
assertThat(serverMetadata).hasSize(fakeService.count.get());
Expand Down Expand Up @@ -368,7 +374,8 @@ public void testPrepareQuery() {
public void testNoCookieSucceedReadRows() {
fakeService.returnCookie = false;

client.readRows(Query.create("fake-table")).iterator().hasNext();
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
ArrayList<Row> ignored = Lists.newArrayList(client.readRows(Query.create("fake-table")));

assertThat(fakeService.count.get()).isGreaterThan(1);
assertThat(serverMetadata).hasSize(fakeService.count.get());
Expand Down Expand Up @@ -476,7 +483,9 @@ public void testNoCookieSucceedReadChangeStream() {
public void testNoCookieSucceedGenerateInitialChangeStreamParition() {
fakeService.returnCookie = false;

client.generateInitialChangeStreamPartitions("table").iterator().hasNext();
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
ArrayList<Range.ByteStringRange> ignored =
Lists.newArrayList(client.generateInitialChangeStreamPartitions("table"));

assertThat(fakeService.count.get()).isGreaterThan(1);
assertThat(serverMetadata).hasSize(fakeService.count.get());
Expand Down Expand Up @@ -546,8 +555,8 @@ public void sendHeaders(Metadata headers) {
.setInstanceId("fake-instance");

try (BigtableDataClient client = BigtableDataClient.create(settings.build())) {

client.readRows(Query.create("table")).iterator().hasNext();
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
ArrayList<Row> ignored = Lists.newArrayList(client.readRows(Query.create("table")));

Metadata lastMetadata = serverMetadata.get(fakeService.count.get() - 1);

Expand All @@ -567,7 +576,8 @@ public void testAllMethodsAreCalled() {
// This test ensures that all methods respect the retry cookie except for the ones that are
// explicitly added to the methods list. It requires that any newly method is exercised in this
// test. This is enforced by introspecting grpc method descriptors.
client.readRows(Query.create("fake-table")).iterator().hasNext();
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
ArrayList<Row> ignored = Lists.newArrayList(client.readRows(Query.create("fake-table")));

fakeService.count.set(0);
client.mutateRow(RowMutation.create("fake-table", "key").setCell("cf", "q", "v"));
Expand All @@ -590,7 +600,9 @@ public void testAllMethodsAreCalled() {
ReadModifyWriteRow.create("fake-table", "key").append("cf", "q", "v"));

fakeService.count.set(0);
client.generateInitialChangeStreamPartitions("fake-table").iterator().hasNext();
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
ArrayList<Range.ByteStringRange> ignored2 =
Lists.newArrayList(client.generateInitialChangeStreamPartitions("fake-table"));

fakeService.count.set(0);
for (ChangeStreamRecord record :
Expand All @@ -617,7 +629,8 @@ public void testCookieSetWithBigtableClientFactory() throws Exception {
BigtableDataClient client1 = factory.createDefault();
BigtableDataClient client2 = factory.createForAppProfile("app-profile");

client1.readRows(Query.create("fake-table")).iterator().hasNext();
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
ArrayList<Row> ignored = Lists.newArrayList(client1.readRows(Query.create("fake-table")));

assertThat(fakeService.count.get()).isGreaterThan(1);
assertThat(serverMetadata).hasSize(fakeService.count.get());
Expand All @@ -638,7 +651,8 @@ public void testCookieSetWithBigtableClientFactory() throws Exception {
fakeService.count.set(0);
serverMetadata.clear();

client2.readRows(Query.create("fake-table")).iterator().hasNext();
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
ArrayList<Row> ignored2 = Lists.newArrayList(client2.readRows(Query.create("fake-table")));

assertThat(fakeService.count.get()).isGreaterThan(1);
assertThat(serverMetadata).hasSize(fakeService.count.get());
Expand Down Expand Up @@ -666,7 +680,8 @@ public void testDisableRoutingCookie() throws IOException {
// is added.
settings.stubSettings().setEnableRoutingCookie(false);
try (BigtableDataClient client = BigtableDataClient.create(settings.build())) {
client.readRows(Query.create("fake-table")).iterator().hasNext();
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
ArrayList<Row> ignored = Lists.newArrayList(client.readRows(Query.create("fake-table")));
assertThat(fakeService.count.get()).isEqualTo(2);
fakeService.count.set(0);

Expand Down Expand Up @@ -695,7 +710,9 @@ public void testDisableRoutingCookie() throws IOException {
assertThat(fakeService.count.get()).isEqualTo(2);
fakeService.count.set(0);

client.generateInitialChangeStreamPartitions("fake-table").iterator().hasNext();
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
ArrayList<Range.ByteStringRange> ignored2 =
Lists.newArrayList(client.generateInitialChangeStreamPartitions("fake-table"));
assertThat(fakeService.count.get()).isEqualTo(2);
fakeService.count.set(0);

Expand Down
Loading
Loading