jetty.project
jetty.project copied to clipboard
Async servlet which re-dispatches should not yield 503 during graceful shutdown
When using Jetty with Spring MVC's DeferredResult async support, graceful shutdown doesn't work properly, even after the fix for #2717. What appears to be happening is that, when the DeferredResult.setResult() is called, eventually Spring's WebAsyncManager calls through to AsyncContext.dispatch() which re-dispatches back to the servlet. Since Jetty checks at dispatch time (ContextHandler.doScope(...)) whether the server is shutting down, this ends up yielding an error 503, even though the request was actually completed.
It seems like returning 503 on a partially-executed request is against usual HTTP error semantics -- I think a lot of reverse proxies will retry 503 automatically, which may not be appropriate if the underlying operation was not idempotent.
It seems like, for graceful shutdown to work as designed, the _availability=SHUTDOWN state should not cause 503 on dispatch if the request has already started handling.
Uploaded a test script here: https://gist.github.com/bba4850b0a8ba94d37cfa7bf6bbcb8bc
I would expect this to return the "Handled" message, but instead it yields a 503.
This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.