diff --git a/netty/src/main/java/io/grpc/netty/NettyServerTransport.java b/netty/src/main/java/io/grpc/netty/NettyServerTransport.java index f22ff97a32c3..82ed972552f9 100644 --- a/netty/src/main/java/io/grpc/netty/NettyServerTransport.java +++ b/netty/src/main/java/io/grpc/netty/NettyServerTransport.java @@ -19,6 +19,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.MoreObjects; import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; import io.grpc.InternalChannelz.SocketStats; @@ -50,6 +51,10 @@ class NettyServerTransport implements ServerTransport { private static final Logger connectionLog = Logger.getLogger( String.format("%s.connections", NettyServerTransport.class.getName())); + // Some exceptions are not very useful and add too much noise to the log + private static final ImmutableList QUIET_EXCEPTIONS = ImmutableList.of( + "NativeIoException" /* Netty exceptions */); + private final InternalLogId logId; private final Channel channel; private final ChannelPromise channelUnused; @@ -178,7 +183,8 @@ Channel channel() { */ @VisibleForTesting static Level getLogLevel(Throwable t) { - if (t.getClass().equals(IOException.class)) { + if (t.getClass().equals(IOException.class) + || QUIET_EXCEPTIONS.contains(t.getClass().getSimpleName())) { return Level.FINE; } return Level.INFO; diff --git a/netty/src/test/java/io/grpc/netty/NettyServerTransportTest.java b/netty/src/test/java/io/grpc/netty/NettyServerTransportTest.java index 71b0723157f1..41e7791a2b85 100644 --- a/netty/src/test/java/io/grpc/netty/NettyServerTransportTest.java +++ b/netty/src/test/java/io/grpc/netty/NettyServerTransportTest.java @@ -56,4 +56,13 @@ class ExtendedIoException extends IOException {} assertThat(e.getMessage()).isNull(); assertThat(getLogLevel(e)).isEqualTo(Level.INFO); } + + @Test + public void fakeNettyNativeIoException() { + class NativeIoException extends IOException {} + + NativeIoException fakeNativeIoException = new NativeIoException(); + + assertThat(getLogLevel(fakeNativeIoException)).isEqualTo(Level.FINE); + } }