mirror of https://github.com/grpc/grpc-java.git
parent
54b7847a7f
commit
1573e0d400
|
|
@ -19,6 +19,7 @@ package io.grpc.netty;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.common.base.Preconditions;
|
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.ListenableFuture;
|
||||||
import com.google.common.util.concurrent.SettableFuture;
|
import com.google.common.util.concurrent.SettableFuture;
|
||||||
import io.grpc.InternalChannelz.SocketStats;
|
import io.grpc.InternalChannelz.SocketStats;
|
||||||
|
|
@ -50,6 +51,10 @@ class NettyServerTransport implements ServerTransport {
|
||||||
private static final Logger connectionLog = Logger.getLogger(
|
private static final Logger connectionLog = Logger.getLogger(
|
||||||
String.format("%s.connections", NettyServerTransport.class.getName()));
|
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<String> QUIET_EXCEPTIONS = ImmutableList.of(
|
||||||
|
"NativeIoException" /* Netty exceptions */);
|
||||||
|
|
||||||
private final InternalLogId logId;
|
private final InternalLogId logId;
|
||||||
private final Channel channel;
|
private final Channel channel;
|
||||||
private final ChannelPromise channelUnused;
|
private final ChannelPromise channelUnused;
|
||||||
|
|
@ -178,7 +183,8 @@ class NettyServerTransport implements ServerTransport {
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static Level getLogLevel(Throwable t) {
|
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.FINE;
|
||||||
}
|
}
|
||||||
return Level.INFO;
|
return Level.INFO;
|
||||||
|
|
|
||||||
|
|
@ -56,4 +56,13 @@ public class NettyServerTransportTest {
|
||||||
assertThat(e.getMessage()).isNull();
|
assertThat(e.getMessage()).isNull();
|
||||||
assertThat(getLogLevel(e)).isEqualTo(Level.INFO);
|
assertThat(getLogLevel(e)).isEqualTo(Level.INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void fakeNettyNativeIoException() {
|
||||||
|
class NativeIoException extends IOException {}
|
||||||
|
|
||||||
|
NativeIoException fakeNativeIoException = new NativeIoException();
|
||||||
|
|
||||||
|
assertThat(getLogLevel(fakeNativeIoException)).isEqualTo(Level.FINE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue