Skip to content

Commit a05b656

Browse files
authored
Add GuardedBy suppressions in RetriableStream
1 parent 6b04fc1 commit a05b656

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

core/src/main/java/io/grpc/internal/RetriableStream.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ abstract class RetriableStream<ReqT> implements ClientStream {
121121
this.throttle = throttle;
122122
}
123123

124+
@SuppressWarnings("GuardedBy")
124125
@Nullable // null if already committed
125126
@CheckReturnValue
126127
private Runnable commit(final Substream winningSubstream) {
@@ -138,6 +139,8 @@ private Runnable commit(final Substream winningSubstream) {
138139

139140
final Future<?> retryFuture;
140141
if (scheduledRetry != null) {
142+
// TODO(b/145386688): This access should be guarded by 'this.scheduledRetry.lock'; instead
143+
// found: 'this.lock'
141144
retryFuture = scheduledRetry.markCancelled();
142145
scheduledRetry = null;
143146
} else {
@@ -146,6 +149,8 @@ private Runnable commit(final Substream winningSubstream) {
146149
// cancel the scheduled hedging if it is scheduled prior to the commitment
147150
final Future<?> hedgingFuture;
148151
if (scheduledHedging != null) {
152+
// TODO(b/145386688): This access should be guarded by 'this.scheduledHedging.lock'; instead
153+
// found: 'this.lock'
149154
hedgingFuture = scheduledHedging.markCancelled();
150155
scheduledHedging = null;
151156
} else {
@@ -338,6 +343,7 @@ public void runWith(Substream substream) {
338343
drain(substream);
339344
}
340345

346+
@SuppressWarnings("GuardedBy")
341347
private void pushbackHedging(@Nullable Integer delayMillis) {
342348
if (delayMillis == null) {
343349
return;
@@ -356,6 +362,8 @@ private void pushbackHedging(@Nullable Integer delayMillis) {
356362
return;
357363
}
358364

365+
// TODO(b/145386688): This access should be guarded by 'this.scheduledHedging.lock'; instead
366+
// found: 'this.lock'
359367
futureToBeCancelled = scheduledHedging.markCancelled();
360368
scheduledHedging = future = new FutureCanceller(lock);
361369
}
@@ -381,6 +389,7 @@ private final class HedgingRunnable implements Runnable {
381389
public void run() {
382390
callExecutor.execute(
383391
new Runnable() {
392+
@SuppressWarnings("GuardedBy")
384393
@Override
385394
public void run() {
386395
// It's safe to read state.hedgingAttemptCount here.
@@ -392,6 +401,9 @@ public void run() {
392401
FutureCanceller future = null;
393402

394403
synchronized (lock) {
404+
// TODO(b/145386688): This access should be guarded by
405+
// 'HedgingRunnable.this.scheduledHedgingRef.lock'; instead found:
406+
// 'RetriableStream.this.lock'
395407
if (scheduledHedgingRef.isCancelled()) {
396408
cancelled = true;
397409
} else {
@@ -695,10 +707,13 @@ private boolean hasPotentialHedging(State state) {
695707
&& !state.hedgingFrozen;
696708
}
697709

710+
@SuppressWarnings("GuardedBy")
698711
private void freezeHedging() {
699712
Future<?> futureToBeCancelled = null;
700713
synchronized (lock) {
701714
if (scheduledHedging != null) {
715+
// TODO(b/145386688): This access should be guarded by 'this.scheduledHedging.lock'; instead
716+
// found: 'this.lock'
702717
futureToBeCancelled = scheduledHedging.markCancelled();
703718
scheduledHedging = null;
704719
}

0 commit comments

Comments
 (0)