Since Jetty12, StatisticHandler is no longer to check shutdown state. JettyServer failed to count active request count correctly. Insted of StatisticHandler, Jetty12 introduce GracefulHandler.
Spring-Boot uses StaticstaticHandler as a active request counter in Jetty11. It was ok because StaticstaticHandler count active request count in acount of shutdown state internally.
https://github.com/jetty/jetty.project/blob/jetty-11.0.x/jetty-server/src/main/java/org/eclipse/jetty/server/handler/StatisticsHandler.java#L146-L168
But As of Jetty12 StaticstaticHandler doesn't see shutdown state. https://github.com/jetty/jetty.project/blob/jetty-12.0.x/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/StatisticsHandler.java#L70-L74
We can use GracefulHandler instead of StaticsticHandler and it'll success to count active request count on shutdown phase. https://github.com/jetty/jetty.project/blob/jetty-12.0.x/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/GracefulHandler.java#L89-L116
Comment From: yokotaso
Sorry, it is my misunderstanding that Graceful shutdown is broken. I've investegated cause of curious log happend in my production environment. and Log content is like bellow:
handleException /actuator/prometheus org.springframework.web.context.request.async.AsyncRequestNotUsableException: ServletOutputStream failed to write: java.util.concurrent.TimeoutException: Idle timeout expired: 30000/30000 ms
handleException /actuator/prometheus java.io.IOException: java.util.concurrent.TimeoutException: Idle timeout expired: 30000/30000 ms
In order to understand cause of log, I have read jetty and spring-boot codes, and found StatiticsHandler is no longer check state of Shutdown. So I thought it is better to use GracefulHandler instead of StatisticHandler in GracefulShutdown.
Comment From: wilkinsona
Thanks for the additional details.
Spring Boot's graceful shutdown doesn't rely on the statistics handler being aware of the shutdown state. It only needs its count of the currently active requests. It may be that we could achieve the same with GracefulHandler but I'm not aware of anything that would mean that it will improve graceful shutdown with Jetty or indeed that it will fix the problem that you're seeing. As such, I'm going to decline this change as I don't think we should make it without a strong reason to do so.