Community
Participate
Working Groups
Build Identifier: Jetty version 8.0.4.v20111024 When shutting down jetty using ShutdownHandler, the call to shutdownServer will wrap a InterruptedException in a RuntimeException, polluting the log with an WARN level log message. Fix: AbstractLifeCycle.stop should swallow InterruptedException silently. (or ShutdownServer.handle could do this). An example of a message: 375582 [qtp1356374432-21] WARN org.eclipse.jetty.util.component.AbstractLifeCycle - FAILED qtp1356374432{8<=0<=1/254,0}#FAILED: java.lang.InterruptedException: sleep interrupted java.lang.InterruptedException: sleep interrupted at java.lang.Thread.sleep(Native Method) at org.eclipse.jetty.util.thread.QueuedThreadPool.doStop(QueuedThreadPool.java:134) at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:84) at org.eclipse.jetty.util.component.AggregateLifeCycle.doStop(AggregateLifeCycle.java:59) at org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:64) at org.eclipse.jetty.server.handler.HandlerWrapper.doStop(HandlerWrapper.java:102) at org.eclipse.jetty.server.Server.doStop(Server.java:323) at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:84) at org.eclipse.jetty.server.handler.ShutdownHandler.shutdownServer(ShutdownHandler.java:140) at org.eclipse.jetty.server.handler.ShutdownHandler.handle(ShutdownHandler.java:115) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110) at org.eclipse.jetty.server.Server.handle(Server.java:350) at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:442) at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:924) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:582) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533) at java.lang.Thread.run(Thread.java:679) 375588 [qtp1356374432-21] WARN org.eclipse.jetty.util.component.AbstractLifeCycle - FAILED org.eclipse.jetty.server.Server@1e4bb369: java.lang.InterruptedException: sleep interrupted java.lang.InterruptedException: sleep interrupted at java.lang.Thread.sleep(Native Method) at org.eclipse.jetty.util.thread.QueuedThreadPool.doStop(QueuedThreadPool.java:134) at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:84) at org.eclipse.jetty.util.component.AggregateLifeCycle.doStop(AggregateLifeCycle.java:59) at org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:64) at org.eclipse.jetty.server.handler.HandlerWrapper.doStop(HandlerWrapper.java:102) at org.eclipse.jetty.server.Server.doStop(Server.java:323) at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:84) at org.eclipse.jetty.server.handler.ShutdownHandler.shutdownServer(ShutdownHandler.java:140) at org.eclipse.jetty.server.handler.ShutdownHandler.handle(ShutdownHandler.java:115) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110) at org.eclipse.jetty.server.Server.handle(Server.java:350) at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:442) at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:924) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:582) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533) at java.lang.Thread.run(Thread.java:679) 375591 [qtp1356374432-21] WARN org.eclipse.jetty.server.HttpConnection - /shutdown?token=sdgklnslhawoirnasiln java.lang.RuntimeException: Shutting down server at org.eclipse.jetty.server.handler.ShutdownHandler.handle(ShutdownHandler.java:119) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110) at org.eclipse.jetty.server.Server.handle(Server.java:350) at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:442) at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:924) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:582) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533) at java.lang.Thread.run(Thread.java:679) Caused by: java.lang.InterruptedException: sleep interrupted at java.lang.Thread.sleep(Native Method) at org.eclipse.jetty.util.thread.QueuedThreadPool.doStop(QueuedThreadPool.java:134) at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:84) at org.eclipse.jetty.util.component.AggregateLifeCycle.doStop(AggregateLifeCycle.java:59) at org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:64) at org.eclipse.jetty.server.handler.HandlerWrapper.doStop(HandlerWrapper.java:102) at org.eclipse.jetty.server.Server.doStop(Server.java:323) at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:84) at org.eclipse.jetty.server.handler.ShutdownHandler.shutdownServer(ShutdownHandler.java:140) at org.eclipse.jetty.server.handler.ShutdownHandler.handle(ShutdownHandler.java:115) ... 13 more Reproducible: Always
Johannes, I've committed this change in ShutdownHandler.handle: try { shutdownServer(); } + catch (InterruptedException e) + { + LOG.ignore(e); + } catch (Exception e) { throw new RuntimeException("Shutting down server",e); } You can get ignored exceptions reported in the log if you set the Log LEVEL to "ALL". Is that sufficient? Jan
(In reply to comment #1) > Johannes, > > I've committed this change in ShutdownHandler.handle: > > try > { > shutdownServer(); > } > + catch (InterruptedException e) > + { > + LOG.ignore(e); > + } > catch (Exception e) > { > throw new RuntimeException("Shutting down server",e); > } > > You can get ignored exceptions reported in the log if you set the Log LEVEL to > "ALL". > > Is that sufficient? > This scratches my itch and I'm happy to accept the change. But _I think_ it will still have the following problems: org.eclipse.jetty.util.thread.QueuedThreadPool.doStop(QueuedThreadPool.java:134) may fail to wait for all threads, as the loop is terminated. org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:84) will set the object (Server?) to failed instead of stopped. org.eclipse.jetty.util.component.AggregateLifeCycle.doStop(AggregateLifeCycle.java:59) -> the other LifeCycle objects in the server will not be shut down, as AggregateLifeCycle.doStop is aborted (I haven't been able to verify this - how do I use the code on the trunk?) I think InterruptedException isn't really an exceptional case. If you're trying to shut down stuff, threads will be interrupted and that's normal. Personally, I'd want to swallow this exception at a lower level. I'd do it in QueuedThreadPool.doStop(). But I may be splitting hairs.. I'll leave the decision to you. I'm happy with your change as well.
Hi Johannes, I solved it a different way - I created a separate thread to stop the Server instance, rather than use the thread from the pool that is handling the request (which would interrupt itself). If you want to test this out, then the easiest thing to do is to checkout master from git and build it locally ("mvn clean install" at the top level will do it). cheers Jan
(In reply to comment #3) > Hi Johannes, > > I solved it a different way - I created a separate thread to stop the Server > instance, rather than use the thread from the pool that is handling the request > (which would interrupt itself). > > If you want to test this out, then the easiest thing to do is to checkout > master from git and build it locally ("mvn clean install" at the top level will > do it). > Looks and sounds good. (Although the master branch is on version 7 and I'm currently using version 8) Sorry about the late response.
Johannes, The fix has been incorporated into the jetty-8 branch, so please check it out and build it locally. cheers Jan