Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jetty 12 - Introduce GracefulShutdownHandler and Test #9174

Merged
merged 10 commits into from
Jan 23, 2023

Conversation

joakime
Copy link
Contributor

@joakime joakime commented Jan 16, 2023

  • started with removing @Disabled from GracefulStopTest.java

+ started with removing `@Disabled` from `GracefulStopTest.java`
@joakime joakime added this to the 12.0.x milestone Jan 16, 2023
@joakime joakime requested review from gregw and sbordet January 16, 2023 14:28
@joakime joakime self-assigned this Jan 16, 2023
@joakime joakime requested a review from sbordet January 16, 2023 23:08
@joakime joakime requested a review from gregw January 18, 2023 23:43
@joakime joakime requested a review from sbordet January 19, 2023 18:48
Comment on lines 68 to 78
// Increment the counter before the test for isShutdown(), to avoid race conditions.
ShutdownTrackingCallback shutdownCallback = new ShutdownTrackingCallback(request, response, callback);

Handler handler = getHandler();
if (handler == null || !isStarted() || isShutdown())
{
if (LOG.isDebugEnabled())
LOG.debug("Service Unavailable: {}", request.getHttpURI());
Response.writeError(request, response, shutdownCallback, HttpStatus.SERVICE_UNAVAILABLE_503);
return true;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still does not feel correct. If we are not started, then we should not be processing the request, even for a 503.

Suggested change
// Increment the counter before the test for isShutdown(), to avoid race conditions.
ShutdownTrackingCallback shutdownCallback = new ShutdownTrackingCallback(request, response, callback);
Handler handler = getHandler();
if (handler == null || !isStarted() || isShutdown())
{
if (LOG.isDebugEnabled())
LOG.debug("Service Unavailable: {}", request.getHttpURI());
Response.writeError(request, response, shutdownCallback, HttpStatus.SERVICE_UNAVAILABLE_503);
return true;
}
Handler handler = getHandler();
if (handler == null || !isStarted())
return false;
// Increment the counter before the test for isShutdown(), to avoid race conditions.
ShutdownTrackingCallback shutdownCallback = new ShutdownTrackingCallback(request, response, callback);
if (isShutdown())
{
if (LOG.isDebugEnabled())
LOG.debug("Service Unavailable: {}", request.getHttpURI());
Response.writeError(request, response, shutdownCallback, HttpStatus.SERVICE_UNAVAILABLE_503);
return true;
}

The handler==null case can be before or after.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

@joakime joakime requested review from sbordet and gregw January 20, 2023 18:10
@joakime
Copy link
Contributor Author

joakime commented Jan 20, 2023

Before I dive into the jetty-start module for this ...

I'm wondering if this is the right name for this handler?
It doesn't provide GracefulShutdown, it manages the requests during graceful shutdown.
So how about GracefulRequestHandler instead?

@joakime joakime merged commit 26a4ee5 into jetty-12.0.x Jan 23, 2023
@joakime joakime deleted the fix/jetty-12.0.x/core-graceful-shutdown-handler branch January 23, 2023 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants