Skip to content

Commit bfc2b4e

Browse files
committed
Add errorprone and supress existing errors
1 parent 603a79d commit bfc2b4e

24 files changed

+155
-0
lines changed

google-cloud-spanner-executor/src/main/java/com/google/cloud/executor/spanner/CloudClientExecutor.java

+2
Original file line numberDiff line numberDiff line change
@@ -2863,6 +2863,8 @@ private com.google.spanner.v1.StructType buildStructType(StructReader struct) {
28632863
}
28642864

28652865
/** Convert a struct to a proto(value list) for constructing result rows and struct values. */
2866+
// Suppressed for initial Error Prone rollout.
2867+
@SuppressWarnings({"ProtoBuilderReturnValueIgnored", "ReturnValueIgnored"})
28662868
private com.google.spanner.executor.v1.ValueList buildStruct(StructReader struct) {
28672869
com.google.spanner.executor.v1.ValueList.Builder structBuilder =
28682870
com.google.spanner.executor.v1.ValueList.newBuilder();

google-cloud-spanner-executor/src/main/java/com/google/cloud/executor/spanner/CloudExecutorImpl.java

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ public StreamObserver<SpannerAsyncActionRequest> executeActionAsync(
7272
// Create a top-level OpenTelemetry span for streaming request.
7373
Tracer tracer = WorkerProxy.openTelemetrySdk.getTracer(CloudClientExecutor.class.getName());
7474
Span span = tracer.spanBuilder("java_systest_execute_actions_stream").setNoParent().startSpan();
75+
// Suppressed for initial Error Prone rollout.
76+
@SuppressWarnings("MustBeClosedChecker")
7577
Scope scope = span.makeCurrent();
7678

7779
final String traceId = span.getSpanContext().getTraceId();

google-cloud-spanner/src/main/java/com/google/cloud/spanner/AbstractReadContext.java

+2
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ protected boolean isRouteToLeader() {
212212
return false;
213213
}
214214

215+
// Suppressed for initial Error Prone rollout.
216+
@SuppressWarnings("GuardedBy")
215217
@GuardedBy("lock")
216218
@Override
217219
void beforeReadOrQueryLocked() {

google-cloud-spanner/src/main/java/com/google/cloud/spanner/OpenTelemetryApiTracer.java

+2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ Span getSpan() {
7777

7878
@Override
7979
public Scope inScope() {
80+
// Suppressed for initial Error Prone rollout.
81+
@SuppressWarnings("MustBeClosedChecker")
8082
final io.opentelemetry.context.Scope openTelemetryScope = span.makeCurrent();
8183
return openTelemetryScope::close;
8284
}

google-cloud-spanner/src/main/java/com/google/cloud/spanner/Options.java

+2
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,8 @@ void appendToOptions(Options options) {
10251025
options.filter = filter;
10261026
}
10271027

1028+
// Suppressed for initial Error Prone rollout.
1029+
@SuppressWarnings("EqualsHashCode")
10281030
@Override
10291031
public boolean equals(Object o) {
10301032
if (o == this) return true;

google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java

+30
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,8 @@ public PooledSessionFuture replaceSession(
587587
}
588588
}
589589

590+
// Suppressed for initial Error Prone rollout.
591+
@SuppressWarnings("GuardedBy")
590592
@Override
591593
public PooledSessionFuture denyListSession(
592594
RetryOnDifferentGrpcChannelException retryException, PooledSessionFuture session) {
@@ -1768,6 +1770,8 @@ public ApiFuture<Empty> asyncClose() {
17681770
return ApiFutures.immediateFuture(Empty.getDefaultInstance());
17691771
}
17701772

1773+
// Suppressed for initial Error Prone rollout.
1774+
@SuppressWarnings("GuardedBy")
17711775
@Override
17721776
public void close() {
17731777
synchronized (lock) {
@@ -1848,12 +1852,16 @@ public SessionImpl getDelegate() {
18481852
return this.delegate;
18491853
}
18501854

1855+
// Suppressed for initial Error Prone rollout.
1856+
@SuppressWarnings("GuardedBy")
18511857
@Override
18521858
public void markBusy(ISpan span) {
18531859
this.delegate.setCurrentSpan(span);
18541860
this.state = SessionState.BUSY;
18551861
}
18561862

1863+
// Suppressed for initial Error Prone rollout.
1864+
@SuppressWarnings("GuardedBy")
18571865
private void markClosing() {
18581866
this.state = SessionState.CLOSING;
18591867
}
@@ -2091,6 +2099,8 @@ void maintainPool() {
20912099
removeLongRunningSessions(currTime);
20922100
}
20932101

2102+
// Suppressed for initial Error Prone rollout.
2103+
@SuppressWarnings("GuardedBy")
20942104
private void removeIdleSessions(Instant currTime) {
20952105
synchronized (lock) {
20962106
// Determine the minimum last use time for a session to be deemed to still be alive. Remove
@@ -2190,6 +2200,8 @@ void removeLongRunningSessions(Instant currentTime) {
21902200
}
21912201
}
21922202

2203+
// Suppressed for initial Error Prone rollout.
2204+
@SuppressWarnings("GuardedBy")
21932205
private void removeLongRunningSessions(
21942206
final Instant currentTime,
21952207
final InactiveTransactionRemovalOptions inactiveTransactionRemovalOptions) {
@@ -2691,6 +2703,8 @@ private void invalidateSession(PooledSession session) {
26912703
}
26922704
}
26932705

2706+
// Suppressed for initial Error Prone rollout.
2707+
@SuppressWarnings("GuardedBy")
26942708
private Tuple<PooledSession, Integer> findSessionToKeepAlive(
26952709
Queue<PooledSession> queue, Instant keepAliveThreshold, int numAlreadyChecked) {
26962710
int numChecked = 0;
@@ -2885,6 +2899,8 @@ private void releaseSession(PooledSession session, boolean isNewSession) {
28852899
}
28862900

28872901
/** Releases a session back to the pool. This might cause one of the waiters to be unblocked. */
2902+
// Suppressed for initial Error Prone rollout.
2903+
@SuppressWarnings("GuardedBy")
28882904
private void releaseSession(
28892905
PooledSession session, boolean isNewSession, @Nullable Integer position) {
28902906
Preconditions.checkNotNull(session);
@@ -2945,13 +2961,17 @@ private void releaseSession(
29452961
* running many small, quick queries using a small number of parallel threads. This can cause a
29462962
* high TPS, without actually having a high degree of parallelism.
29472963
*/
2964+
// Suppressed for initial Error Prone rollout.
2965+
@SuppressWarnings("GuardedBy")
29482966
@VisibleForTesting
29492967
boolean shouldRandomize() {
29502968
return this.options.getRandomizePositionQPSThreshold() > 0
29512969
&& this.transactionsPerSecond >= this.options.getRandomizePositionQPSThreshold()
29522970
&& this.numSessionsInUse >= this.numChannels;
29532971
}
29542972

2973+
// Suppressed for initial Error Prone rollout.
2974+
@SuppressWarnings("GuardedBy")
29552975
private boolean isUnbalanced(PooledSession session) {
29562976
int channel = session.getChannel();
29572977
int numChannels = sessionClient.getSpanner().getOptions().getNumChannels();
@@ -3054,10 +3074,14 @@ private void handleCreateSessionsFailure(SpannerException e, int count) {
30543074
}
30553075
}
30563076

3077+
// Suppressed for initial Error Prone rollout.
3078+
@SuppressWarnings("GuardedBy")
30573079
void setResourceNotFoundException(ResourceNotFoundException e) {
30583080
this.resourceNotFoundException = MoreObjects.firstNonNull(this.resourceNotFoundException, e);
30593081
}
30603082

3083+
// Suppressed for initial Error Prone rollout.
3084+
@SuppressWarnings("GuardedBy")
30613085
private void decrementPendingClosures(int count) {
30623086
pendingClosure -= count;
30633087
if (pendingClosure == 0) {
@@ -3070,6 +3094,8 @@ private void decrementPendingClosures(int count) {
30703094
* {@code IllegalStateException}. The returned future blocks till all the sessions created in this
30713095
* pool have been closed.
30723096
*/
3097+
// Suppressed for initial Error Prone rollout.
3098+
@SuppressWarnings("GuardedBy")
30733099
ListenableFuture<Void> closeAsync(ClosedException closedException) {
30743100
ListenableFuture<Void> retFuture = null;
30753101
synchronized (lock) {
@@ -3269,6 +3295,8 @@ public void onSessionCreateFailure(Throwable t, int createFailureForSessionCount
32693295
* Initializes and creates Spanner session relevant metrics using OpenCensus. When coupled with an
32703296
* exporter, it allows users to monitor client behavior.
32713297
*/
3298+
// Suppressed for initial Error Prone rollout.
3299+
@SuppressWarnings("GuardedBy")
32723300
private void initOpenCensusMetricsCollection(
32733301
MetricRegistry metricRegistry,
32743302
List<LabelValue> labelValues,
@@ -3402,6 +3430,8 @@ private void initOpenCensusMetricsCollection(
34023430
* Initializes and creates Spanner session relevant metrics using OpenTelemetry. When coupled with
34033431
* an exporter, it allows users to monitor client behavior.
34043432
*/
3433+
// Suppressed for initial Error Prone rollout.
3434+
@SuppressWarnings("GuardedBy")
34053435
private void initOpenTelemetryMetricsCollection(
34063436
OpenTelemetry openTelemetry,
34073437
Attributes attributes,

google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerImpl.java

+2
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,8 @@ public void close() {
375375
close(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
376376
}
377377

378+
// Suppressed for initial Error Prone rollout.
379+
@SuppressWarnings("GuardedBy")
378380
void close(long timeout, TimeUnit unit) {
379381
List<ListenableFuture<Void>> closureFutures;
380382
synchronized (this) {

google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java

+4
Original file line numberDiff line numberDiff line change
@@ -1828,6 +1828,8 @@ public static void enableOpenCensusTraces() {
18281828
* Always resets the activeTracingFramework. This variable is used for internal testing, and is
18291829
* not a valid production scenario
18301830
*/
1831+
// Suppressed for initial Error Prone rollout.
1832+
@SuppressWarnings("GuardedBy")
18311833
@ObsoleteApi(
18321834
"The OpenCensus project is deprecated. Use enableOpenTelemetryTraces to switch to"
18331835
+ " OpenTelemetry traces")
@@ -2023,6 +2025,8 @@ private ApiTracerFactory createApiTracerFactory(
20232025
return new CompositeTracerFactory(apiTracerFactories);
20242026
}
20252027

2028+
// Suppressed for initial Error Prone rollout.
2029+
@SuppressWarnings("GuardedBy")
20262030
private ApiTracerFactory getDefaultApiTracerFactory() {
20272031
if (isEnableApiTracing()) {
20282032
if (activeTracingFramework == TracingFramework.OPEN_TELEMETRY) {

google-cloud-spanner/src/main/java/com/google/cloud/spanner/TraceWrapper.java

+2
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ ISpan getBlankSpan() {
130130
}
131131
}
132132

133+
// Suppressed for initial Error Prone rollout.
134+
@SuppressWarnings("MustBeClosedChecker")
133135
IScope withSpan(ISpan span) {
134136
if (SpannerOptions.getActiveTracingFramework().equals(TracingFramework.OPEN_TELEMETRY)) {
135137
OpenTelemetrySpan openTelemetrySpan;

google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/AbstractBaseUnitOfWork.java

+2
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,8 @@ public <ReqT, RespT> ApiCallContext configure(
401401
}
402402
future.addListener(
403403
new Runnable() {
404+
// Suppressed for initial Error Prone rollout.
405+
@SuppressWarnings("GuardedBy")
404406
@Override
405407
public void run() {
406408
synchronized (this) {

google-cloud-spanner/src/test/java/com/google/cloud/spanner/AbstractReadContextTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ public void testExecuteBatchDmlLastStatement() {
303303
.getLastStatements());
304304
}
305305

306+
// Suppressed for initial Error Prone rollout.
307+
@SuppressWarnings("JUnit4TestNotRun")
306308
public void executeSqlRequestBuilderWithRequestOptions() {
307309
ExecuteSqlRequest request =
308310
context

google-cloud-spanner/src/test/java/com/google/cloud/spanner/BackupIdTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public void basics() {
4040
assertThat(bid.toString()).isEqualTo(name);
4141
}
4242

43+
// Suppressed for initial Error Prone rollout.
44+
@SuppressWarnings("CheckReturnValue")
4345
@Test
4446
public void badName() {
4547
IllegalArgumentException e =

google-cloud-spanner/src/test/java/com/google/cloud/spanner/ChannelUsageTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ public void testCreatesNumChannels() {
228228
assertEquals(numChannels, batchCreateSessionLocalIps.size());
229229
}
230230

231+
// Suppressed for initial Error Prone rollout.
232+
@SuppressWarnings("CheckReturnValue")
231233
@Test
232234
public void testUsesAllChannels() throws InterruptedException {
233235
final int multiplier = 2;

google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseAdminClientTest.java

+4
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,8 @@ public void instanceListDatabaseOperations()
631631
assertThat(instance.listDatabaseOperations().iterateAll()).hasSize(6);
632632
}
633633

634+
// Suppressed for initial Error Prone rollout.
635+
@SuppressWarnings("CheckReturnValue")
634636
@Test
635637
public void instanceListDatabaseOperationsWithMetadata() throws Exception {
636638
Instance instance =
@@ -713,6 +715,8 @@ public void instanceListBackupOperations()
713715
assertThat(instance.listBackupOperations().iterateAll()).hasSize(2);
714716
}
715717

718+
// Suppressed for initial Error Prone rollout.
719+
@SuppressWarnings("CheckReturnValue")
716720
@Test
717721
public void instanceListBackupOperationsWithProgress() throws InvalidProtocolBufferException {
718722
Instance instance =

google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseClientImplTest.java

+20
Original file line numberDiff line numberDiff line change
@@ -2331,6 +2331,8 @@ public void singleUse() {
23312331
DatabaseClientImpl client =
23322332
(DatabaseClientImpl)
23332333
spanner.getDatabaseClient(DatabaseId.of(TEST_PROJECT, TEST_INSTANCE, TEST_DATABASE));
2334+
// Suppressed for initial Error Prone rollout.
2335+
@SuppressWarnings("GuardedBy")
23342336
Set<PooledSessionFuture> checkedOut = client.pool.checkedOutSessions;
23352337
assertThat(checkedOut).isEmpty();
23362338
try (ResultSet rs = client.singleUse().executeQuery(SELECT1)) {
@@ -3919,6 +3921,8 @@ public void testCreateSessionsFailure_shouldNotPropagateToCloseMethod() {
39193921
@Test
39203922
public void testReadWriteTransaction_usesOptions() {
39213923
SessionPool pool = mock(SessionPool.class);
3924+
// Suppressed for initial Error Prone rollout.
3925+
@SuppressWarnings("DoNotMock")
39223926
PooledSessionFuture session = mock(PooledSessionFuture.class);
39233927
when(pool.getSession()).thenReturn(session);
39243928
TransactionOption option = mock(TransactionOption.class);
@@ -3935,6 +3939,8 @@ public void testReadWriteTransaction_usesOptions() {
39353939
@Test
39363940
public void testTransactionManager_usesOptions() {
39373941
SessionPool pool = mock(SessionPool.class);
3942+
// Suppressed for initial Error Prone rollout.
3943+
@SuppressWarnings("DoNotMock")
39383944
PooledSessionFuture session = mock(PooledSessionFuture.class);
39393945
when(pool.getSession()).thenReturn(session);
39403946
TransactionOption option = mock(TransactionOption.class);
@@ -3948,6 +3954,8 @@ public void testTransactionManager_usesOptions() {
39483954
@Test
39493955
public void testRunAsync_usesOptions() {
39503956
SessionPool pool = mock(SessionPool.class);
3957+
// Suppressed for initial Error Prone rollout.
3958+
@SuppressWarnings("DoNotMock")
39513959
PooledSessionFuture session = mock(PooledSessionFuture.class);
39523960
when(pool.getSession()).thenReturn(session);
39533961
TransactionOption option = mock(TransactionOption.class);
@@ -3961,6 +3969,8 @@ public void testRunAsync_usesOptions() {
39613969
@Test
39623970
public void testTransactionManagerAsync_usesOptions() {
39633971
SessionPool pool = mock(SessionPool.class);
3972+
// Suppressed for initial Error Prone rollout.
3973+
@SuppressWarnings("DoNotMock")
39643974
PooledSessionFuture session = mock(PooledSessionFuture.class);
39653975
when(pool.getSession()).thenReturn(session);
39663976
TransactionOption option = mock(TransactionOption.class);
@@ -4240,6 +4250,8 @@ public void singleUseNoAction_ClearsCheckedOutSession() {
42404250
DatabaseClientImpl client =
42414251
(DatabaseClientImpl)
42424252
spanner.getDatabaseClient(DatabaseId.of(TEST_PROJECT, TEST_INSTANCE, TEST_DATABASE));
4253+
// Suppressed for initial Error Prone rollout.
4254+
@SuppressWarnings("GuardedBy")
42434255
Set<PooledSessionFuture> checkedOut = client.pool.checkedOutSessions;
42444256
assertThat(checkedOut).isEmpty();
42454257

@@ -4255,6 +4267,8 @@ public void singleUseReadOnlyTransactionNoAction_ClearsCheckedOutSession() {
42554267
DatabaseClientImpl client =
42564268
(DatabaseClientImpl)
42574269
spanner.getDatabaseClient(DatabaseId.of(TEST_PROJECT, TEST_INSTANCE, TEST_DATABASE));
4270+
// Suppressed for initial Error Prone rollout.
4271+
@SuppressWarnings("GuardedBy")
42584272
Set<PooledSessionFuture> checkedOut = client.pool.checkedOutSessions;
42594273
assertThat(checkedOut).isEmpty();
42604274

@@ -4268,6 +4282,8 @@ public void readWriteTransactionNoAction_ClearsCheckedOutSession() {
42684282
DatabaseClientImpl client =
42694283
(DatabaseClientImpl)
42704284
spanner.getDatabaseClient(DatabaseId.of(TEST_PROJECT, TEST_INSTANCE, TEST_DATABASE));
4285+
// Suppressed for initial Error Prone rollout.
4286+
@SuppressWarnings("GuardedBy")
42714287
Set<PooledSessionFuture> checkedOut = client.pool.checkedOutSessions;
42724288
assertThat(checkedOut).isEmpty();
42734289

@@ -4281,6 +4297,8 @@ public void readOnlyTransactionNoAction_ClearsCheckedOutSession() {
42814297
DatabaseClientImpl client =
42824298
(DatabaseClientImpl)
42834299
spanner.getDatabaseClient(DatabaseId.of(TEST_PROJECT, TEST_INSTANCE, TEST_DATABASE));
4300+
// Suppressed for initial Error Prone rollout.
4301+
@SuppressWarnings("GuardedBy")
42844302
Set<PooledSessionFuture> checkedOut = client.pool.checkedOutSessions;
42854303
assertThat(checkedOut).isEmpty();
42864304

@@ -4294,6 +4312,8 @@ public void transactionManagerNoAction_ClearsCheckedOutSession() {
42944312
DatabaseClientImpl client =
42954313
(DatabaseClientImpl)
42964314
spanner.getDatabaseClient(DatabaseId.of(TEST_PROJECT, TEST_INSTANCE, TEST_DATABASE));
4315+
// Suppressed for initial Error Prone rollout.
4316+
@SuppressWarnings("GuardedBy")
42974317
Set<PooledSessionFuture> checkedOut = client.pool.checkedOutSessions;
42984318
assertThat(checkedOut).isEmpty();
42994319

google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ public void testUnspecifiedDialectDefaultsToGoogleStandardSqlDialect() {
165165
assertEquals(Dialect.GOOGLE_STANDARD_SQL, database.getDialect());
166166
}
167167

168+
// Suppressed for initial Error Prone rollout.
169+
@SuppressWarnings("SetUnrecognized")
168170
@Test
169171
public void testUnrecognizedDialectThrowsException() {
170172
assertThrows(

google-cloud-spanner/src/test/java/com/google/cloud/spanner/OpenTelemetryBuiltInMetricsTracerTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ public void testMetricsSingleUseQueryWithAfeEnabled() throws Exception {
279279
}
280280
}
281281

282+
// Suppressed for initial Error Prone rollout.
283+
@SuppressWarnings("CheckReturnValue")
282284
@Test
283285
public void testMetricsWithGaxRetryUnaryRpc() {
284286
Stopwatch stopwatch = Stopwatch.createStarted();

google-cloud-spanner/src/test/java/com/google/cloud/spanner/RandomResultSetGenerator.java

+2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ public class RandomResultSetGenerator {
8686
.build(),
8787
};
8888

89+
// Suppressed for initial Error Prone rollout.
90+
@SuppressWarnings({"ProtoBuilderReturnValueIgnored", "ReturnValueIgnored"})
8991
private static ResultSetMetadata generateMetadata() {
9092
StructType.Builder rowTypeBuilder = StructType.newBuilder();
9193
for (int col = 0; col < TYPES.length; col++) {

google-cloud-spanner/src/test/java/com/google/cloud/spanner/SelectRandomBenchmark.java

+2
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ public void teardown() throws Exception {
113113
}
114114

115115
/** Measures the time needed to execute a burst of read requests. */
116+
// Suppressed for initial Error Prone rollout.
117+
@SuppressWarnings("ReturnValueIgnored")
116118
@Benchmark
117119
public void burstRead(final BenchmarkState server) throws Exception {
118120
int totalQueries = server.maxSessions * 8;

0 commit comments

Comments
 (0)