diff options
author | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2019-04-29 16:10:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-29 16:10:49 +0200 |
commit | 7eab85d1fc8d1978a48dce1851a05fa623fd4d2b (patch) | |
tree | 2ce424ffdcf4300965fb5f667918358db84add92 | |
parent | b0109b176072d1a620822a5ad04e87024554e4fd (diff) | |
parent | 87a8437a628310373d9db95b4ca66a9e968e8870 (diff) |
Merge pull request #9227 from vespa-engine/bjorncs/jdisc-fix-logging
Bjorncs/jdisc fix logging
-rw-r--r-- | jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/HttpRequestDispatch.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/HttpRequestDispatch.java b/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/HttpRequestDispatch.java index 64e5ce3d33f..2d2632bcf0f 100644 --- a/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/HttpRequestDispatch.java +++ b/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/HttpRequestDispatch.java @@ -22,6 +22,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.nio.charset.StandardCharsets; +import java.util.Arrays; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; import java.util.concurrent.atomic.AtomicBoolean; @@ -131,10 +132,7 @@ class HttpRequestDispatch { error, () -> "Network connection was unexpectedly terminated: " + parent.jettyRequest.getRequestURI()); parent.metricReporter.prematurelyClosed(); - } else if (!(error instanceof CompletionException && error.getCause() instanceof OverloadException - || error instanceof OverloadException - || error instanceof BindingNotFoundException - || error instanceof RequestException)) { + } else if (!isErrorOfType(error, OverloadException.class, BindingNotFoundException.class, RequestException.class)) { log.log(Level.WARNING, "Request failed: " + parent.jettyRequest.getRequestURI(), error); } reportedError = true; @@ -153,6 +151,15 @@ class HttpRequestDispatch { }; } + @SafeVarargs + @SuppressWarnings("varargs") + private static boolean isErrorOfType(Throwable throwable, Class<? extends Throwable>... handledTypes) { + return Arrays.stream(handledTypes) + .anyMatch( + exceptionType -> exceptionType.isInstance(throwable) + || throwable instanceof CompletionException && exceptionType.isInstance(throwable.getCause())); + } + @SuppressWarnings("try") private ServletRequestReader handleRequest() throws IOException { HttpRequest jdiscRequest = HttpRequestFactory.newJDiscRequest(jDiscContext.container, jettyRequest); |