core: Fix ErrorProne errors

This commit is contained in:
Eric Anderson 2016-07-11 16:08:52 -07:00
parent edf2c62fd5
commit d2cc576320
2 changed files with 12 additions and 2 deletions

View File

@ -259,6 +259,15 @@ public final class ManagedChannelImpl extends ManagedChannel implements WithLogI
return balancer; return balancer;
} }
// ErrorProne's GuardedByChecker can't figure out that the idleModeTimer is a nested instance of
// this particular instance. It is worried about something like:
// ManagedChannelImpl a = ...;
// ManagedChannelImpl b = ...;
// a.idleModeTimer = b.idleModeTimer;
// a.cancelIdleTimer(); // access of b.idleModeTimer is guarded by a.lock, not b.lock
//
// _We_ know that isn't happening, so we suppress the warning.
@SuppressWarnings("GuardedByChecker")
@GuardedBy("lock") @GuardedBy("lock")
private void cancelIdleTimer() { private void cancelIdleTimer() {
if (idleModeTimerFuture != null) { if (idleModeTimerFuture != null) {

View File

@ -79,9 +79,10 @@ import javax.annotation.concurrent.GuardedBy;
public final class ServerImpl extends io.grpc.Server { public final class ServerImpl extends io.grpc.Server {
private static final ServerStreamListener NOOP_LISTENER = new NoopListener(); private static final ServerStreamListener NOOP_LISTENER = new NoopListener();
/** Executor for application processing. */ /** Executor for application processing. Safe to read after {@link #start()}. */
private Executor executor; private Executor executor;
@GuardedBy("lock") private boolean usingSharedExecutor; /** Safe to read after {@link #start()}. */
private boolean usingSharedExecutor;
private final InternalHandlerRegistry registry; private final InternalHandlerRegistry registry;
private final HandlerRegistry fallbackRegistry; private final HandlerRegistry fallbackRegistry;
@GuardedBy("lock") private boolean started; @GuardedBy("lock") private boolean started;