Skip to content

Commit d2cc576

Browse files
committed
core: Fix ErrorProne errors
1 parent edf2c62 commit d2cc576

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,15 @@ public void run() {
259259
return balancer;
260260
}
261261

262+
// ErrorProne's GuardedByChecker can't figure out that the idleModeTimer is a nested instance of
263+
// this particular instance. It is worried about something like:
264+
// ManagedChannelImpl a = ...;
265+
// ManagedChannelImpl b = ...;
266+
// a.idleModeTimer = b.idleModeTimer;
267+
// a.cancelIdleTimer(); // access of b.idleModeTimer is guarded by a.lock, not b.lock
268+
//
269+
// _We_ know that isn't happening, so we suppress the warning.
270+
@SuppressWarnings("GuardedByChecker")
262271
@GuardedBy("lock")
263272
private void cancelIdleTimer() {
264273
if (idleModeTimerFuture != null) {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@
7979
public final class ServerImpl extends io.grpc.Server {
8080
private static final ServerStreamListener NOOP_LISTENER = new NoopListener();
8181

82-
/** Executor for application processing. */
82+
/** Executor for application processing. Safe to read after {@link #start()}. */
8383
private Executor executor;
84-
@GuardedBy("lock") private boolean usingSharedExecutor;
84+
/** Safe to read after {@link #start()}. */
85+
private boolean usingSharedExecutor;
8586
private final InternalHandlerRegistry registry;
8687
private final HandlerRegistry fallbackRegistry;
8788
@GuardedBy("lock") private boolean started;

0 commit comments

Comments
 (0)