mirror of https://github.com/grpc/grpc-java.git
okhttp: use FINE log for pure IOExceptions
This commit is contained in:
parent
c166ec2c4e
commit
30f8f26f7a
|
|
@ -25,11 +25,7 @@ import io.grpc.okhttp.internal.framed.FrameWriter;
|
|||
import io.grpc.okhttp.internal.framed.Header;
|
||||
import io.grpc.okhttp.internal.framed.Settings;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import okio.Buffer;
|
||||
|
|
@ -39,10 +35,6 @@ final class ExceptionHandlingFrameWriter implements FrameWriter {
|
|||
|
||||
private static final Logger log = Logger.getLogger(OkHttpClientTransport.class.getName());
|
||||
|
||||
// Some exceptions are not very useful and add too much noise to the log
|
||||
private static final Set<String> QUIET_ERRORS =
|
||||
Collections.unmodifiableSet(new HashSet<>(Arrays.asList("Socket closed")));
|
||||
|
||||
private final TransportExceptionHandler transportExceptionHandler;
|
||||
|
||||
private final FrameWriter frameWriter;
|
||||
|
|
@ -231,9 +223,7 @@ final class ExceptionHandlingFrameWriter implements FrameWriter {
|
|||
*/
|
||||
@VisibleForTesting
|
||||
static Level getLogLevel(Throwable t) {
|
||||
if (t instanceof IOException
|
||||
&& t.getMessage() != null
|
||||
&& QUIET_ERRORS.contains(t.getMessage())) {
|
||||
if (t.getClass().equals(IOException.class)) {
|
||||
return Level.FINE;
|
||||
}
|
||||
return Level.INFO;
|
||||
|
|
|
|||
|
|
@ -71,18 +71,22 @@ public class ExceptionHandlingFrameWriterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void quiet() {
|
||||
public void ioException() {
|
||||
assertThat(getLogLevel(new IOException("Socket closed"))).isEqualTo(Level.FINE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonquiet() {
|
||||
assertThat(getLogLevel(new IOException("foo"))).isEqualTo(Level.INFO);
|
||||
public void ioException_nullMessage() {
|
||||
IOException e = new IOException();
|
||||
assertThat(e.getMessage()).isNull();
|
||||
assertThat(getLogLevel(e)).isEqualTo(Level.FINE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullMessage() {
|
||||
IOException e = new IOException();
|
||||
public void extendedIoException() {
|
||||
class ExtendedIoException extends IOException {}
|
||||
|
||||
ExtendedIoException e = new ExtendedIoException();
|
||||
assertThat(e.getMessage()).isNull();
|
||||
assertThat(getLogLevel(e)).isEqualTo(Level.INFO);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue