-
Notifications
You must be signed in to change notification settings - Fork 2k
Issue #9019 - improve configuration for AbstractConnector shutdownIdleTimeout #14263
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
base: jetty-12.1.x
Are you sure you want to change the base?
Changes from all commits
a65e1bf
42cb6a9
b0536be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,8 @@ | |
| import java.util.function.Function; | ||
|
|
||
| import org.eclipse.jetty.http.HttpStatus; | ||
| import org.eclipse.jetty.server.AbstractConnector; | ||
| import org.eclipse.jetty.server.Connector; | ||
| import org.eclipse.jetty.server.Handler; | ||
| import org.eclipse.jetty.server.HttpStream; | ||
| import org.eclipse.jetty.server.Request; | ||
|
|
@@ -39,6 +41,7 @@ public class GracefulHandler extends Handler.Wrapper implements Graceful | |
| private final AtomicLong _requests = new AtomicLong(); | ||
| private final AtomicLong _streamWrappers = new AtomicLong(); | ||
| private final Shutdown _shutdown; | ||
| private Long _shutdownIdleTimeout; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd use a normal |
||
|
|
||
| public GracefulHandler() | ||
| { | ||
|
|
@@ -74,6 +77,11 @@ public long getCurrentStreamWrapperCount() | |
| return _streamWrappers.longValue(); | ||
| } | ||
|
|
||
| public void setShutdownIdleTimeout(long shutdownIdleTimeout) | ||
| { | ||
| _shutdownIdleTimeout = shutdownIdleTimeout; | ||
| } | ||
|
|
||
| /** | ||
| * Flag indicating that Graceful shutdown has been initiated. | ||
| * | ||
|
|
@@ -131,6 +139,18 @@ protected void doStart() throws Exception | |
| { | ||
| // Reset _shutdown in doStart instead of doStop so that the isShutdown() == true state is preserved while stopped. | ||
| _shutdown.cancel(); | ||
|
|
||
| if (_shutdownIdleTimeout != null) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did this to preserve existing behavior if the So the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it is explicitly set to -1 (so it's not I'd use -1, see above.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well the Javadoc on So if someone wanted to disable the |
||
| { | ||
| for (Connector connector : getServer().getConnectors()) | ||
| { | ||
| if (connector instanceof AbstractConnector abstractConnector) | ||
| { | ||
| abstractConnector.setShutdownIdleTimeout(_shutdownIdleTimeout); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| super.doStart(); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This default does not match what's in the code.
When standalone and not explicitly configured, we want to have the default behavior.
When embedded, we want the same default behavior.
I think a better default would be -1, to maintain backwards compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default behaviour is 1000ms and not -1, for the shutdownIdleTimeout -1 is a special value which means to not change the idleTimeout during the graceful shutdown. The value of 1000ms is the default value from
AbstractConnector.If this property is not set then
GracefulHandler.setShutdownIdleTimeoutis never called so the value remains null, then we never change the default value from that ofAbstractConnector.