Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Jetty behaviour when a java.lang.error is thrown

Hi,

On Tue, Aug 19, 2014 at 1:16 PM, Neil Williams <neil@xxxxxxxxxxx> wrote:
> Situation came up where one of our handlers was throwing a java.lang.error
> and I am wondering what the expected jetty behaviour is.
>
> 2 things I observed:
>
> 1. A response is never sent to the client when an Error is thrown.
> 2. Request logging is incorrect when an error is thrown.
>
> With the following setup:
>
> public class JettyErrorThrowing {
>   public static class ThrowingHandler extends ContextHandler {
>     public ThrowingHandler() {
>       super("/throwerror");
>     }
>
>     public void doHandle(String arg0, Request arg1, HttpServletRequest arg2,
>         HttpServletResponse arg3) throws IOException, ServletException {
>       throw new Error("ThrowingHandler thrown error");
>     }
>   }
>
>   public static void main(String[] args) throws Exception {
>     Server server = new Server(8080);
>
>     RequestLogHandler requestLogHandler = new RequestLogHandler();
>     requestLogHandler.setRequestLog(new
> NCSARequestLog("JettyErrorThrowing.log"));
>     requestLogHandler.setHandler(new ThrowingHandler());
>
>     server.setHandler(requestLogHandler);
>
>     server.start();
>     server.join();
>   }
> }
>
> A request to /throwerror/ will result in the following printed to the
> request log:
> 0:0:0:0:0:0:0:1 -  -  [19/Aug/2014:11:01:57 +0000] "GET /throwerror/
> HTTP/1.1" 200 - "-" "snipped ua"
>
> This is obviously incorrect as the response status is logged as 200 but a
> response is never sent.
>
> What is the expected behaviour on a thrown error?
> Would you like me to file the request log behaviour as a bug?

Yes please.

Thanks !

-- 
Simone Bordet
----
http://cometd.org
http://webtide.com
http://intalio.com
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.


Back to the top