From e15a87f4993d44042a7ac8d7264b71486c3419fe Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 20 Aug 2014 10:27:27 +1000 Subject: [PATCH] 440255 ensure 500 is logged on thrown Errors --- .../main/java/org/eclipse/jetty/server/HttpChannel.java | 5 ++++- .../eclipse/jetty/server/handler/RequestLogHandler.java | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java index ba33c2e461a..ee99477ef8f 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java @@ -361,7 +361,10 @@ public class HttpChannel implements HttpParser.RequestHandler, Runnable, H else { error=true; - throw e; + LOG.warn(String.valueOf(_uri), e); + _state.error(e); + _request.setHandled(true); + handleException(e); } } catch (Exception e) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/RequestLogHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/RequestLogHandler.java index 706b988bffc..f2edf937d25 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/RequestLogHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/RequestLogHandler.java @@ -66,6 +66,9 @@ public class RequestLogHandler extends HandlerWrapper @Override public void onError(AsyncEvent event) throws IOException { + HttpServletResponse response = (HttpServletResponse)event.getAsyncContext().getResponse(); + if (!response.isCommitted()) + response.setStatus(500); } @@ -91,6 +94,12 @@ public class RequestLogHandler extends HandlerWrapper { super.handle(target, baseRequest, request, response); } + catch(Error|IOException|ServletException|RuntimeException e) + { + if (!response.isCommitted()) + response.setStatus(500); + throw e; + } finally { if (_requestLog != null && baseRequest.getDispatcherType().equals(DispatcherType.REQUEST))