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

Commit db46382

Browse files
chore: clean up warnings pass 2
Change-Id: Iaff267ffb3ed336aa089d6033e3bb36442feefb8
1 parent a15ba8d commit db46382

88 files changed

Lines changed: 475 additions & 431 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

google-cloud-bigtable/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@
427427
<compilerArgs>
428428
<arg>-XDcompilePolicy=simple</arg>
429429
<arg>--should-stop=ifError=FLOW</arg>
430-
<arg>-Xplugin:ErrorProne -XepDisableWarningsInGeneratedCode -Xep:MissingSummary:OFF -Xep:InlineMeSuggester:OFF -Xep:AutoValueImmutableFields:OFF -Xep:ObjectEqualsForPrimitives:OFF</arg>
430+
<arg>-Xplugin:ErrorProne -XepDisableWarningsInGeneratedCode -Xep:MissingSummary:OFF -Xep:InlineMeSuggester:OFF -Xep:AutoValueImmutableFields:OFF -Xep:ObjectEqualsForPrimitives:OFF -Xep:JavaDurationGetSecondsToToSeconds:OFF</arg>
431431

432432
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg>
433433
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public com.google.bigtable.admin.v2.AuthorizedView.SubsetView toProto() {
105105
}
106106

107107
@Override
108+
@SuppressWarnings("EqualsGetClass")
108109
public boolean equals(Object o) {
109110
if (this == o) {
110111
return true;

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ static Type fromProto(com.google.bigtable.admin.v2.Type source) {
5252
return Aggregate.fromProto(source.getAggregateType());
5353
case KIND_NOT_SET:
5454
return Raw.create();
55+
default:
56+
throw new UnsupportedOperationException();
5557
}
56-
throw new UnsupportedOperationException();
5758
}
5859

5960
/** The raw type denotes the absence of a type. */
@@ -204,8 +205,9 @@ static Encoding fromProto(com.google.bigtable.admin.v2.Type.Int64.Encoding sourc
204205
return BigEndianBytes.create();
205206
case ENCODING_NOT_SET:
206207
return BigEndianBytes.create();
208+
default:
209+
throw new UnsupportedOperationException();
207210
}
208-
throw new UnsupportedOperationException();
209211
}
210212

211213
@AutoValue

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/common/Type.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ public SqlType<?> getType(java.lang.String fieldName) {
306306
}
307307

308308
@Override
309+
@SuppressWarnings("EqualsGetClass")
309310
public boolean equals(Object obj) {
310311
if (this == obj) {
311312
return true;
@@ -457,12 +458,12 @@ public Code getCode() {
457458
}
458459

459460
@Override
460-
public java.lang.String toString() {
461+
public final java.lang.String toString() {
461462
return getCode().name() + "{enum=" + getEnumName() + "}";
462463
}
463464

464465
@Override
465-
public boolean equals(Object o) {
466+
public final boolean equals(Object o) {
466467
if (this == o) {
467468
return true;
468469
}
@@ -486,7 +487,7 @@ public boolean equals(Object o) {
486487
}
487488

488489
@Override
489-
public int hashCode() {
490+
public final int hashCode() {
490491
T thisEnum = getForNumber().apply(0);
491492
if (thisEnum == null) {
492493
return getForNumber().hashCode();
@@ -561,6 +562,7 @@ public static SchemalessEnum create(
561562
return new AutoValue_Type_SchemalessEnum(enumName, schemaBundleId);
562563
}
563564

565+
@Override
564566
public abstract java.lang.String getEnumName();
565567

566568
public abstract java.lang.String schemaBundleId();

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataClient.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2697,8 +2697,8 @@ public void readChangeStreamAsync(
26972697
* Executes a SQL Query and returns a ResultSet to iterate over the results. The returned
26982698
* ResultSet instance is not threadsafe, it can only be used from single thread.
26992699
*
2700-
* <p> The {@link BoundStatement} must be built from a {@link PreparedStatement} created using
2701-
* the same instance and app profile.
2700+
* <p>The {@link BoundStatement} must be built from a {@link PreparedStatement} created using the
2701+
* same instance and app profile.
27022702
*
27032703
* <p>Sample code:
27042704
*
@@ -2719,9 +2719,11 @@ public void readChangeStreamAsync(
27192719
* } catch (RuntimeException e) {
27202720
* e.printStackTrace();
27212721
* }
2722+
* }
27222723
* }</pre>
27232724
*
2724-
* @see {@link PreparedStatement} & {@link BoundStatement} for query options.
2725+
* @see PreparedStatement for query options.
2726+
* @see BoundStatement for query options.
27252727
*/
27262728
public ResultSet executeQuery(BoundStatement boundStatement) {
27272729
boundStatement.assertUsingSameStub(stub);

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataSettings.java

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -146,38 +146,34 @@ public static Builder newBuilderForEmulator(String hostname, int port) {
146146
}
147147

148148
/**
149-
* @deprecated OpenCensus support is deprecated and will be removed in a future version
150-
* Enables OpenCensus metric aggregations.
151-
*
152-
* <p>This will register Bigtable client relevant {@link io.opencensus.stats.View}s. When coupled
153-
* with an exporter, it allows users to monitor client behavior.
154-
*
155-
* <p>Please note that in addition to calling this method, the application must:
156-
* <ul>
157-
* <li>Include openensus-impl dependency on the classpath
158-
* <li>Configure an exporter like opencensus-exporter-stats-stackdriver
159-
* </ul>
160-
*
161-
* <p>Example usage for maven:
162-
* <pre>{@code
163-
* <dependency>
164-
* <groupId>io.opencensus</groupId>
165-
* <artifactId>opencensus-impl</artifactId>
166-
* <version>${opencensus.version}</version>
167-
* <scope>runtime</scope>
168-
* </dependency>
169-
*
170-
* <dependency>
171-
* <groupId>io.opencensus</groupId>
172-
* <artifactId>opencensus-exporter-stats-stackdriver</artifactId>
173-
* <version>${opencensus.version}</version>
174-
* </dependency>
175-
* </pre>
149+
* @deprecated OpenCensus support is deprecated and will be removed in a future version Enables
150+
* OpenCensus metric aggregations.
151+
* <p>This will register Bigtable client relevant {@link io.opencensus.stats.View}s. When
152+
* coupled with an exporter, it allows users to monitor client behavior.
153+
* <p>Please note that in addition to calling this method, the application must:
154+
* <ul>
155+
* <li>Include openensus-impl dependency on the classpath
156+
* <li>Configure an exporter like opencensus-exporter-stats-stackdriver
157+
* </ul>
158+
* <p>Example usage for maven:
159+
* <pre>{@code
160+
* <dependency>
161+
* <groupId>io.opencensus</groupId>
162+
* <artifactId>opencensus-impl</artifactId>
163+
* <version>${opencensus.version}</version>
164+
* <scope>runtime</scope>
165+
* </dependency>
176166
*
177-
* Java:
178-
* <pre>{@code
179-
* StackdriverStatsExporter.createAndRegister();
180-
* BigtableDataSettings.enableOpenCensusStats();
167+
* <dependency>
168+
* <groupId>io.opencensus</groupId>
169+
* <artifactId>opencensus-exporter-stats-stackdriver</artifactId>
170+
* <version>${opencensus.version}</version>
171+
* </dependency>
172+
* }</pre>
173+
* Java:
174+
* <pre>{@code
175+
* StackdriverStatsExporter.createAndRegister();
176+
* BigtableDataSettings.enableOpenCensusStats();
181177
* }</pre>
182178
*/
183179
@Deprecated

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/AbstractProtoStructReader.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ public abstract class AbstractProtoStructReader implements StructReader {
4141
abstract List<Value> values();
4242

4343
// Force subclasses to override equals and hashcode. We need this for tests.
44+
@Override
4445
public abstract boolean equals(Object other);
4546

47+
@Override
4648
public abstract int hashCode();
4749

4850
/**

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/PreparedStatementImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import com.google.api.core.InternalApi;
2121
import com.google.auto.value.AutoValue;
2222
import com.google.cloud.bigtable.data.v2.models.sql.BoundStatement;
23-
import com.google.cloud.bigtable.data.v2.models.sql.BoundStatement.Builder;
2423
import com.google.cloud.bigtable.data.v2.models.sql.PreparedStatement;
2524
import com.google.cloud.bigtable.data.v2.models.sql.SqlType;
2625
import com.google.cloud.bigtable.data.v2.stub.EnhancedBigtableStub;
@@ -76,7 +75,7 @@ public static PreparedStatement create(
7675

7776
@Override
7877
public BoundStatement.Builder bind() {
79-
return new Builder(this, paramTypes);
78+
return new BoundStatement.Builder(this, paramTypes);
8079
}
8180

8281
/**

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/RegexUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
*/
3434
@InternalApi
3535
public final class RegexUtil {
36-
private static final byte[] NULL_BYTES = "\\x00".getBytes();
36+
private static final byte[] NULL_BYTES = {0};
3737

3838
private RegexUtil() {}
3939

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/csm/opencensus/MetricsTracer.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import java.util.concurrent.CancellationException;
3838
import java.util.concurrent.TimeUnit;
3939
import java.util.concurrent.atomic.AtomicBoolean;
40+
import java.util.concurrent.atomic.AtomicLong;
4041
import javax.annotation.Nullable;
4142

4243
class MetricsTracer extends BigtableTracer {
@@ -55,17 +56,15 @@ class MetricsTracer extends BigtableTracer {
5556
private final AtomicBoolean opFinished = new AtomicBoolean();
5657
private final Stopwatch operationTimer = Stopwatch.createStarted();
5758
private final Stopwatch firstResponsePerOpTimer = Stopwatch.createStarted();
58-
private long operationResponseCount = 0;
5959

6060
// Attempt level metrics
6161
private int attemptCount = 0;
6262
private Stopwatch attemptTimer;
63-
private long attemptResponseCount = 0;
6463

6564
private volatile int attempt = 0;
6665

6766
private volatile boolean reportBatchingLatency = false;
68-
private volatile long batchThrottledLatency = 0;
67+
private final AtomicLong batchThrottledLatency = new AtomicLong(0);
6968
private MetadataExtractorInterceptor.SidebandData sidebandData;
7069

7170
MetricsTracer(
@@ -145,7 +144,6 @@ public void attemptStarted(int attemptNumber) {
145144
attempt = attemptNumber;
146145
attemptCount++;
147146
attemptTimer = Stopwatch.createStarted();
148-
attemptResponseCount = 0;
149147
}
150148

151149
@Override
@@ -200,11 +198,11 @@ private void recordAttemptCompletion(@Nullable Throwable throwable) {
200198
}
201199

202200
if (reportBatchingLatency) {
203-
measures.put(RpcMeasureConstants.BIGTABLE_BATCH_THROTTLED_TIME, batchThrottledLatency);
201+
measures.put(RpcMeasureConstants.BIGTABLE_BATCH_THROTTLED_TIME, batchThrottledLatency.get());
204202

205203
// Reset batch throttling latency for next attempt. This can't be done in attemptStarted
206204
// because batching flow control will add batching latency before the attempt has started.
207-
batchThrottledLatency = 0;
205+
batchThrottledLatency.set(0);
208206
}
209207

210208
// Patch the throwable until it's fixed in gax. When an attempt failed,
@@ -228,8 +226,6 @@ public void responseReceived() {
228226
if (firstResponsePerOpTimer.isRunning()) {
229227
firstResponsePerOpTimer.stop();
230228
}
231-
attemptResponseCount++;
232-
operationResponseCount++;
233229
}
234230

235231
@Override
@@ -245,7 +241,7 @@ public void setSidebandData(MetadataExtractorInterceptor.SidebandData sidebandDa
245241
@Override
246242
public void batchRequestThrottled(long totalThrottledMs) {
247243
reportBatchingLatency = true;
248-
batchThrottledLatency += totalThrottledMs;
244+
batchThrottledLatency.addAndGet(totalThrottledMs);
249245
}
250246

251247
private TagContextBuilder newTagCtxBuilder() {

0 commit comments

Comments
 (0)